我有一个DOM
这样如何找到div内的所有数字并添加<span></span>使用jquery的标签?
<div class="main_div">
<p>A car averages 27 miles per gallon. If gas costs $4.04 per gallon, which of the following is closest to how much the gas would cost for this car to travel 2,727 typical miles?</p>
</div>
我只是想span标签添加到所有号码,如
<div class="main_div">
<p>A car averages <span> 27 </span> miles per gallon. If gas costs $<span>4.04</span> per gallon, which of the following is closest to how much the gas would cost for this car to travel <span>2,727</span> typical miles?</p>
</div>
我都试过,可能的方式和检查这个环节太
Javascript/jquery get number value inside of element
How to get number inside a div with jquery
Jquery - Adding all numbers inside span of a particular class
但这只能选择第一个数字只是我想选择div内的所有号码,如果该div包含20个号码我只需要添加跨度所有的数字,这可能吗?最佳答案必须明白..
@vijayP它的数字是'.'作为小数点,'''作为千位分隔符。 – Justinas
@LinkinTED你能告诉我你怎么能发现这是重复的,因为我有搜索这么多的方式,我已经添加到我的问题的链接,但我找不到这个? –
@trincot你能告诉我这个吗? –