大家好,我想我的移动应用程序中的两个html文件说page1.html和page2.html.在page2.html中,我有一个表,单击行我显示了一个警告.如果假设我从page1转到page2.html然后点击表格,它会显示一次警告框.如果我按下后退按钮然后它转到page1.html如果我想再次在page2.html上点击表格行然后这个时间警报显示2次.如果我在第1页再次返回并再次登录page2.html然后这次点击行显示警报3次,依此类推……
我的page2.html表格如下:
<div id="myTable" align="center" data-theme="b"></div>
<script type="text/javascript">
var theader = '<table border="1" id=\"tableId\">\n';
var colheader = '<tr id="headingtab" bgcolor="#D68B8B"><th>Name</th><th>Address</th><th>City</th><th>LTP</th><th>State</th><th>Country</th><th>Mob No</th></tr>\n';
tbody = colheader;
tbody += '<td>';
tbody += "QQQQQQQQQQQQQQQQQQQQQ";
tbody += '</td>';
tbody += '<td>';
tbody += "QQQQQQQQQQQQQQQQQQQQQ";
tbody += '</td>'
tbody += '<td>';
tbody += "QQQQQQQQQQQQQQQQQQQQQ";
tbody += '</td>'
tbody += '<td>';
tbody += "QQQQQQQQQQQQQQQQQQQQQ";
tbody += '</td>'
tbody += '<td>';
tbody += "QQQQQQQQQQQQQQQQQQQQQ";
tbody += '</td>'
tbody += '<td>';
tbody += "QQQQQQQQQQQQQQQQQQQQQ";
tbody += '</td>'
tbody += '<td>';
tbody += "QQQQQQQQQQQQQQQQQQQQQ";
tbody += '</td>'
tbody += '</tr>\n';
var tfooter = '</table>';
document.getElementById('myTable').innerHTML = theader + tbody + tfooter;
</script>
<script type="text/javascript">
$("#tableId tr td").live("click",function()
{
console.log("??????????????????????????????");
alert("Row Click");
});
</script>
</div>
我希望每次点击只显示一次警报.怎么做?任何帮助将不胜感激.提前致谢.
最佳答案 使用jquery函数.one()
$(#tableId tr td).one("click",function()
{
console.log("??????????????????????????????");
alert("Row Click")
}
这可能对你有所帮助