js 获取data-属性值
生活随笔
收集整理的這篇文章主要介紹了
js 获取data-属性值
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
// html code
<span class="1pc_price" data-price="<?php echo Country::change('$29.95',$money_type) . "<br/>Download Instantly"; ?>"></span>
// js code
var price_1pc_hb = document.getElementsByClassName('1pc_price')[0].getAttribute('data-price');
?注意
document.getElementsByClassName('1pc_price')后面有[0],不然會報錯。轉載于:https://www.cnblogs.com/ryanzheng/p/9037240.html
總結
以上是生活随笔為你收集整理的js 获取data-属性值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: selenium - Select类 -
- 下一篇: 【MAC】Ncnn 编译so文件方案