你还可以在"data-*" 属性里使用json语法,例如
<div id="awesome-json" data-awesome='{"game":"on",”name”:”bb”}'></div>
<a data-awesome='{"id":"${puser.personId }","name":"${puser.nickName }","personState":"${puser.personState }",}' class="change change_right frozen">冻结</a>
$(".frozen").click(function(){
var puserId = $(this).data("awesome").id; //用户ID
var puserName = $(this).data("awesome").name; //用户姓名
var puserState = $(this).data("awesome").personState; //用户状态
<a data-personId="${psuper.personId }" data-superId=${psuper.supervisorId } class="relieveOne" >解冻</a>
$(".freeze").click(function(){
var personIds=$(this).attr("data-personId");
var superIds=$(this).attr("data-superId");
20180828:今天获取属性值的时候出现了undefined的情况,我的代码是这样的
<button data-awesome='{"usuallyId":${item.optionsId },"usuallyName":${item.optionsName }}'></button>
几番折腾发现,只有usuallyId属性正常,加上usuallyName就不行,然后加上双引号就行了也就是说JavaScript虽然是弱类型语言,涉及字符串时有情况还是需要引号的,正确写法如下
<button data-awesome='{"usuallyId":${item.optionsId },"usuallyName":"${item.optionsName }"}'></button>