Reputation: 9432
The problem is not that difficult, I just can't get my head around it (noob at Jquery). The problem all comes down to when clicking a <span>
getting it`s text and print it;
$('span').click(function(){
var t= ???;
alert(t);
});
How can i get it's text??? NOTE: Each span does not have an id or class, any span clicked must output a message. Each span is generated dinamic via PHP and I need it's value.
Upvotes: 5
Views: 11315
Reputation: 754
To get the span id without click
id = $("span.ClassName").attr('id');
Upvotes: 0
Reputation: 19588
use .text() (http://docs.jquery.com/Text())
$('span').click(function(){
alert($(this).text());
});
Upvotes: 3
Reputation: 93493
$('span').click(function(){
var t = $(this).text();
alert(t);
});
Upvotes: 10