选择innerhtml的部分 [英] selecting parts of the innerhtml
本文介绍了选择innerhtml的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图从网站的innerhtml中获取部分数据。特别是这个innerhtml中的价格:
在线价格:$ 15.31
我只需要15.31。我怎么能这样做?
谢谢!
解决方案
15.31
我只需要15.31。我怎么能这样做?
谢谢!
参考 - 如何使用jQuery或Javascript将货币字符串转换为double? [ ^ ]。
引用:删除所有非点/数字:
var currency = < span class =code-string>
1,100.00;
var number = Number (currency.replace(/ [^ 0-9 \。 ] + / g, ));
Hi, Im trying to get part of the data from an innerhtml in a website. specifically the price in this innerhtml:
Online Price: $15.31
I only need the 15.31 from this. How can I do it?
Thanks!
解决方案
15.31
I only need the 15.31 from this. How can I do it?
Thanks!
Refer - How to convert a currency string to a double with jQuery or Javascript?[^].
Quote:Remove all non dot / digits:
var currency = "
1,100.00"; var number = Number(currency.replace(/[^0-9\.]+/g,""));
这篇关于选择innerhtml的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文