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],不然会报错。
posted @ 2018-05-14 17:36  Ryan_zheng  阅读(1384)  评论(0编辑  收藏  举报