如何触发jquery.each()函数?
jQuery('img.svg').each(function() {
console.log("some code");
});
具有.svg类的图像将动态创建。
我试图通过
触发$('img.svg').each(); //Not trigger
$('img.svg').trigger('each'); // Not trigger
答案 0 :(得分:1)
如果动态创建类.svg
。因此,当img具有.each
类时,您需要触发.svg
。例如:
function addClass(){
jQuery('img').addClass('svg');
jQuery('img.svg').each(function() {
console.log("some code");
});
}