在我将其与$("#id")一起使用后,相同的代码就不起作用了.append.代码看起来像没有加载jq
same code not work after i use it with $("#id").append.the code look like the code that not load jquery and jquery moblie
我使用了这个html代码,它运行得很好。按钮可以点击和改变一个页面,就像我想。
<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>
现在我想将id和name添加到sqlite数据库中。在我使用$('#my_data'(.empty((.append((添加i wan以显示在div id="my_data"下。我的append代码与我上面使用的代码相同。
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);
}
它显示在屏幕上,但看起来像是当我没有导入jquery和jquery mobile时(我做了,它在第一个代码中运行良好(,然后点击按钮,它就不工作了。看起来它没有加载jquery和jquery mobile。当我删除jquery和jquery移动导入并运行第一个代码时,它看起来是一样的。如何使其发挥作用?
ps.my点击代码。
$(document).ready(function () {
$(".info").on("tap",
function () {
document.location.href = "./customer_info.html" + "#id=" + $(this).attr("value") + "&name=" + uid;
});
});
--------------------------更新1------------------------
我尝试了下面的代码,但它仍然不起作用
$(document).ready(function () {
$('#my_data').on("tap",".info",
function () {
document.location.href = "./customer_info.html" + "#id=" + $(this).attr("value") + "&name=" + uid;
});
});
要获得jQM样式,必须告诉jQM在将小部件附加到页面后增强它们。对于jQM 1.3.x:
$('#my_data').empty().append(htmlstring).trigger("create");
对于jQM 1.4.x,您可以使用
$('#my_data').empty().append(htmlstring).enhanceWithin("");
对于单击处理程序,uid来自哪里?如果它有空格和特殊字符,则必须对其进行url编码以包含在链接地址encodeURIComponent(uid)
中。若要传递查询字符串,请使用"?"而不是.html.后面的"#">
$('#my_data').on("tap",".info", function () {
var uid = "jui. co";
var url = "./customer_info.html" + "?id=" + $(this).prop("value") + "&name=" + encodeURIComponent(uid);
alert(url);
location.href = url;
});
演示
function () {
document.location.href = "./customer_info.html" + "#id=" + $(this).attr("value") + "&name=" + uid;
});
尝试用?id
替换#id
相关文章:
- 在我的代码中,实体类"卡片展示”;不起作用
- "“用户友好”;vimeo嵌入,从url获取嵌入代码
- 我想制作一个代码;a“;变成“;b”"b”;变成“;c”;,等等
- 为什么使用“;javascript:<代码>"令人不快的
- 页面不可滚动,其中ng include=“”;函数()"-该代码已不再使用
- 我怎么能"DRY”;调出我的html和javascript代码
- 如何在Wordpress文件中添加自定义javascript代码"single.php”;
- "ReferenceError:角度未定义“;之前已成功使用的代码
- 为什么可以't我将JS代码置于<script src=“">代码</脚本>
- 在服务器上浏览代码:如何获得“;窗口”"位置”;以及其他“;窗口“;属性,通常是浏览器对象
- Nashorn故障排除”;方法代码太大"例外
- 如何使HtmlGenericControl属性runat="服务器”;.从代码中访问它
- 什么是“;警告-可疑代码.'getprop'运算符未被使用"意思是
- "未捕获的类型错误:未定义的不是函数“;在JavaScript代码块中
- "可以't从释放的脚本执行代码“t”;在IE9中调用date.getHours()时
- 如何在Javascript代码中使用变量Ex:src="htp://www.url.com/file.php?
- node.js mysql查询product_id响应"代码“:"ER_BAD_FIELD_ERRO
- Backbone.js打印“;函数String(){〔本机代码〕}"而不是模型属性
- 在提交之前执行js代码"提交”;在铁轨上的红宝石
- 为什么JS代码"var a=document.querySelector('a[data-a=1]