I use this html code and it works well. The button can be clicked and change a page like I want to.
<table id="myTable" style="background-color: #FAF0BA; width: 95%">
<thead>
<tr align="center" style="background-color: #009972; color: #FAF0BA;">
<td>#id</td>
<td>name</td>
<td>info</td>
</tr>
</thead>
<tr align="center" style="background-color: #8AABBA; color: #FAF0BA;" >
<td>1</td>
<td>jui co.</td>
<td><button style="background-color: #FAF0BA; color:#00CCA5;" data-role ="button" data-mini="true" data-inline="true" data-icon ="info" class="info" value="1">info</button></td>
</tr>
</table>
now i want to add id and name into sqlite database. After i add i wan to show is under div id="my_data" using$('#my_data').empty().append(). my code that append is the same as code i use above.
function renderList(tx, results) {
var htmlstring = '<table id="myTable" style="background-color: #FAF0BA; width: 95%">\n';
htmlstring += "<thead>\n";
htmlstring += "<div id=\"current_login\" style=\"background-color: #009972;\"></div>\n";
htmlstring += "<tr align=\"center\" style=\"background-color: #009972; color: #FAF0BA;\">\n";
htmlstring += "<td>#id</td>\n";
htmlstring += "<td>name</td>\n";
htmlstring += "<td>info</td>\n";
htmlstring += "</tr>\n";
htmlstring +="</thead>\n";
var len = results.rows.length;
for (var i = 0; i < len; i++) {
htmlstring += "<tr align=\"center\" style=\"background-color: #8AABBA; color: #FAF0BA;\" >";
htmlstring += "<td>" + results.rows.item(i).cid + "</td>";
htmlstring += "<td>" + results.rows.item(i).name + "</td>";
htmlstring += "<td><button style=\"background-color: #FAF0BA; color:#00CCA5;\" data-role =\"button\" data-mini=\"true\" data-inline=\"true\" data-icon =\"info\" class=\"info\" value=\"" + results.rows.item(i).cid + "\">info</button></td>";
htmlstring += "</tr>";
}
htmlstring +="</table>";
$('#my_data').empty().append(htmlstring);
}
It shows on screen but is look like when I did't import jquery and jquery mobile (which I did and it works well on the first code) and went I click the button, it doesn't work. It look like it isn't loading jquery and jquery mobile. It looks the same when I remove jquery and jquery mobile import and run the first code. How to make it work?
ps.my click code.
$(document).ready(function () {
$(".info").on("tap",
function () {
document.location.href = "./customer_info.html" + "#id=" + $(this).attr("value") + "&name=" + uid;
});
});
--------------------------update1------------------------
i try the code below but it still don't work
$(document).ready(function () {
$('#my_data').on("tap",".info",
function () {
document.location.href = "./customer_info.html" + "#id=" + $(this).attr("value") + "&name=" + uid;
});
});