使用JS或PHP从span元素中获取值

I have a few values in a few spans and I want to extract each number to a string and then perform calculations. I have the following code which will just get the value from the "example" id but how can I get the values from all the spans as well

$(function() {
    $a = $('#example').text();
    window.alert($a);    
});

<div id="example">
<span>1</span>
<span>,</span>
<span>9</span>
<span>9</span>
<span>3</span>
<span>,</span>
<span>1</span>
</div>
查看全部
dtujfmfs06058
dtujfmfs06058
2018/01/18 13:54
  • php
  • html
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复