最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery change data attribute value - Stack Overflow

programmeradmin3浏览0评论

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

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

Share Improve this question asked Sep 23, 2015 at 14:47 oussama kamaloussama kamal 1,0373 gold badges23 silver badges46 bronze badges 3
  • Looks like that class should be an id if its unique which appears to be. – Andy Commented Sep 23, 2015 at 14:47
  • That should work as written, can you reproduce the failure? And define what "not working" means in the context of your question. – David Thomas Commented Sep 23, 2015 at 14:49
  • 4 It works for me – Stryner Commented Sep 23, 2015 at 14:52
Add a ment  | 

1 Answer 1

Reset to default 5

Try to use

$('.total_payment').data('basetotal', '50.00');
发布评论

评论列表(0)

  1. 暂无评论