使用jquery更改数据属性的值

时间:2017-10-12 11:41:42

标签: jquery

知道为什么这不起作用?

$( "#trn_one" ).prepend( '<div class="panel-group"> <div class="panel panel-primary"><div class="panel-body" id="panel_trn_1" style="color:black; text-shadow: none; text-align: center; height: 70px;">This is the beginning of the training for GeoNode platform. Click the NEXT button and follow the instrucitons to explore the platform. <br/> <br/> </div> <button type="button" id="next_trn" class="btn btn-primary" data-step=1> Next </button><br/> <br/></div>' );


$("#next_trn").on("click", function() {
  alert("it doesnt change the data attribute");
  $('#next_trn').data('step','2'); 
});

我尝试更改按钮的data-step属性。但是没有用。

0 个答案:

没有答案