Is there any way that I can get the id of an element from something like:
Some text
As of jQuery 1.6, you could (and some would say should) use .prop instead of .attr
$('.test').click(function(){ alert($(this).prop('id')); });
It is discussed further in this post: .prop() vs .attr()