开发者

jQuery - Selecting the value of a span via classname

开发者 https://www.devze.com 2023-03-25 09:27 出处:网络
I want to get the value of a span by开发者_如何学JAVA knowing only the class name. In the document there is only one span with that class. I tried like this:

I want to get the value of a span by开发者_如何学JAVA 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?


demo

works fine for me

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

精彩评论

暂无评论...
验证码 换一张
取 消