我需要一种方法来解析网页的动态内容。例如,如果我需要为每个元素添加一个带有"test“类的类,我可以这样做:
$(".test").each(function(index, element)
{
if(!$(this).data("parsed"))
{
$(this).data("parsed", true);
//all my operation - Example :
$(this).addClass("new-class");
}
});这是可行的,但目前仅适用于html。如果我第二次将新的html附加到我的页面,我的脚本将不会解析它。我会想办法做到这一点。有没有一个方法叫什么时候内容变了?例如,在每个append、html、ajax请求等上?
发布于 2013-10-08 22:17:57
这可能是一种自己的解决方案:
var original_append = $.fn.append;
$.fn.append = function()
{
console.log(arguments);
//my code
return original_append.apply(this, arguments);
}https://stackoverflow.com/questions/19250016
复制相似问题