Nikolay
Nikolay

Reputation: 1

jQuery - Selecting the value of a span via classname

I want to get the value of a span by knowing only the class name. In the document there is only one span with that class. I tried like this:

$('span.foo').text();

But it doesn't return anything. How can I do that?

Upvotes: 0

Views: 4966

Answers (1)

genesis
genesis

Reputation: 50982

demo

works fine for me

<span class="foo"> 
bar 
</span> 
<script> 
alert($('span.foo').text()); 
</script>

Upvotes: 2

Related Questions