Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  63] [ 2]  / answers: 1 / hits: 53474  / 12 Years ago, wed, may 2, 2012, 12:00:00

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?


More From » jquery

 Answers
7

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


[#85836] Tuesday, May 1, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaitlynd

Total Points: 470
Total Questions: 108
Total Answers: 120

Location: Faroe Islands
Member since Thu, Apr 8, 2021
3 Years ago
;