Get value of element on which the event fired

html, javascript, jquery

Solution

Use `$(event.target).text()` to get the text.

Problem

Possible Duplicate: Select inner text (jQuery) I have a span: ``` <span class="test"> target_string </span> ``` And the event, that is fired on click on any element of the page. ``` $('body').click(function(event){ if ($(event.target).attr('class') == 'test'){ alert(???); } } ``` How can I obtain target_string value?

Original source

Related problems