Jquery移动按钮刷新不能编程工作

jquery mobile button refresh not working programmatically

本文关键字:编程 工作 不能 刷新 移动 按钮 Jquery      更新时间:2023-09-26

我有一个表,它被逐行动态添加到dom中。每行的最后一个位置都有一个按钮。可选择删除。

我有问题获得按钮或任何属性的id。然而,样式是应用的。

function makeLeague(){
var tableStart = "<table style='min-width:100%;' id='league-table-custom' class='league-table ui-responsive' data-mode='reflow'><th>TEAM</th><th>PLD</th><th>W</th><th>D</th><th>L</th><th>GF</th><th>GA</th><th>GD</th><TH>PTS</TH><th></th>";
var tableEnd = "</table>";
var tableMid = '' ;
var secondtab = $('#demo1');
leagueSize = league.length;
for(k=0; k<league.length; k++){
tableMid += "<tr>";
for(i=0; i< 9; i++){
tableMid += "<td> " + league[k][i] + "</td>";
}
tableMid += "<td><input type='button' class='remove' value='"+k+"' id="+k+"></td></tr>";
}


secondtab.html(tableStart + tableMid + tableEnd).trigger('create');
$('#demo1').trigger('create'); //tried many combinations/and on own
$('.remove').button();
$('.remove').trigger('create');
}
$('.remove').on('click',function(){
   console.log ($(this).attr.id);});

有没有人有任何建议我在哪里做错了。我阅读了jquery移动文档,他们声明样式按钮被包装在div中。这会影响我的访问吗?或者我可以用一种更好的方式来构建这个函数,从而消除任何问题。

我得到这个工作,我必须遍历dom一点点。当获得值时,我输入$('#pageone').on('click', 'table .remove',function(){ console.log ($(this).attr('id')); });,它工作。不确定这是正常的行为,希望它适用于所有浏览器。谢谢你的建议。

代替$('.remove').on('click',function(){ console.log ($(this).attr.id);});