How to get an ID of a specific element that matches a JQuery selector
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!!!
How to get an ID of a specific element that matches a JQuery selector
===

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!!!