jQuery change data attribute value

不打扰是莪最后的温柔 提交于 2021-01-28 19:09:48

问题


Hello I have the folowing HTML element :

<li class="total_payment" data-basetotal="0.00">
    <span>
        <h5>Total</h5>
    </span>
</li>

I want to change the data-basetotal value from 0.00 to 50.00 with jQuery jQuery v1.7.2 using :

$(document).ready(function(){
$('.total_payment').attr('data-basetotal', '50.00');
});

but it is not working , how can I change the value please?

Thanks


回答1:


Try to use

$('.total_payment').data('basetotal', '50.00');


来源:https://stackoverflow.com/questions/32742738/jquery-change-data-attribute-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!