我想将类添加到具有类'alignleft'的元素。我的代码:JQuery - 如果元素具有类,则添加类
$(document).ready(function() {
if($('.foto').children().hasClass('alignleft')){
$(this).addClass('animated bounceInLeft');
}
});
它不起作用,我不知道为什么。但是,如果我使用$('.foto').children().addClass('animated bounceInLeft');
它将类应用于类'alignleft'的所有子元素。所以问题可能在$(this)
?