用Document解析html,我现在要怎样获取到 ”防触电插座保护盖“ 这个数据
<p class="fb_fx">
<p id="bdshare" class="bdshare_t bds_tools get-codes-bdshare" style="display:none" data="{'comment':'','desc':'防触电插座保护盖 ','text':'防触电插座保护盖 ','title':'防触电插座保护盖 ','url':'http://www.tsdxb.comhttp://item.taobao.com/item.htm?id=521916721437','pic':'http://www.tsdxb.com/otherimg/imgju/2016/0103/7-521916721437.jpg'}">
<a class="bds_tsina" title="分享到新浪微博" href="#"></a>
<a href="#" class="bds_qzone qqkj" title="分享到QQ空间"></a>
<a class="bds_tqq" title="分享到腾讯微博" href="#"></a>
<a href="#" class="bds_mshare mshare" title="一键分享"></a>
</p>
</p>
Try this?
I quite agree with the method of using json parse.
There are three ways to achieve this:
var data = window.document.getElementById('bdshare').getAttribute('data');
var json = JSON.parse(data);
eval('(' + data + ')');
var a = new Function("return " + data); a();
documentby or use jquery