大家好,我假设我的移动应用程序中有两个 html 文件,分别是 page1.html 和 page2.html。在 page2.html 中,我有一个表,单击行时,我显示了一个警报。如果假设我从 page1 转到 page2.html,那么在单击表时它会显示一次警报框。如果我按下返回按钮然后它会转到 page1.html 如果假设我再次转到 page2.html 并单击表格行,那么这次警报显示 2 次。如果我再次返回 page1 并再次访问 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>
我希望每次点击只显示一个时间警报。怎么做?任何帮助将不胜感激。提前致谢。