Is there any way that I can get the id of an element from something like:
Some text
When you add a click event, this returns the element that has been clicked. So you can just use this.id;
this
this.id
$(".test").click(function(){ alert(this.id); });
Example: http://jsfiddle.net/jonathon/rfbrp/