Use the same jquery object in a call
Not sure quite how to describe this but this is what i want to achieve:
$('.class').append($(this).attr("unit"));
but this doesn't a开发者_如何学Cppend anything, i don't believe that $(this) is the element.
Im not sure how to do this, but if there is a better way like attaching code to an event on a div, but i can't think of any triggers that work on load.
You need to use .each()
here to loop though and have this
be what you want, like this:
$('.class').each(function() {
$(this).append($(this).attr("unit"));
});
Inside the .each()
callback closure, this
refers to the current class="class"
element you're on, and runs for each match.
精彩评论