Jquery代码要解决的问题

Jquery Code Sinppets to Solve

本文关键字:问题 解决 代码 Jquery      更新时间:2023-09-26

谁能告诉我这些可能的解决办法是什么?

问题 1:作为表单的网页,其 ID 为"my_form"和一些应用了类"排除"的元素。 如何制作表单的副本并仅从表单的新副本中删除具有排除类的所有元素?

问题 2:检查此代码片段。你认为它应该做什么?为什么不起作用?你会如何解决它?

$("li").each(function () {
    if ($(this).find("ul")) {
        $(this).css("background-color", "gray");
    } else {
        $(this).css("background-color", "white");
    }
});

问题 3:用户抱怨即使在点击播放/暂停按钮后仍在播放音频。鉴于以下实现,为什么会发生这种情况?你会如何解决它?

// Pause Button Implementation:
$("#togglePlayPause").on("click", function () {
    if (audio.paused === true) {
        audio.play();
    } else {
        audio.pause();
    }
});
// when the current audio has played all the way through, read the next element.
audio.addEventListener("ended", function () {
    if (audio.paused === false) {
        var nextElement = _getNextElement();
        // scroll the page so that the next element we're reading is at the top of the browser window.
        $(window).animate(scrollTop: nextElement.offset().top, 400, function () {
            _playElementAudio(nextElement);
        });
    }
});

任何帮助将不胜感激。

问题 1

 $("#form").not(".excluded").clone().appendTo("#anotherForm");