This should be very simple, but I’m blocking on this….
Let’s say, for the sake of argument, that we want to prepend() its ID to each element matching class “class_name”. I thought the right way to do it would be something like:
$(‘.class_name’).prepend($(this).attr(‘id’));
But it does not work. It looks like $(this) is only usable inside event callabacks. But how do I get the ID (or any other attribute) of each specific element?
Many thanks!!!
You could use
.each():Example:
http://jsfiddle.net/d8Uj8/