Reputation: 3748
How can I get this value ? This not works :
<script type="text/javascript" src="/theme/js/jquery1.8.0/jquery.min.js"></script>
<script type="text/javascript">
$('.Text1').click(function () {
$('.Span1').each(function () {
alert($('.Span1').val());
});
});
</script>
I need to get the Span1's value. What I'm doing wrong ?
Edit : Span1 elements are <span>
, that contains text.
Upvotes: 2
Views: 69
Reputation: 34107
demo http://jsfiddle.net/6NTeK/
You are missing : this
& use text to grab text.
Hope rest fits your need :)
Code
$('.Text1').click(function () {
$('.Span1').each(function () {
alert($(this).text());
});
});
Upvotes: 3