我需要使用jquery在表中加载elem。这是代码:为什么脚本只能在我重新加载页面?
在file.html表的代码是:
<table id="tabella_ban_email" class="table table-condensed table-responsive table-hover"></table>
,并在的script.js的代码是:
$(document).ready(function() {
var email_table=$('#tabella_ban_email');
if(email_table!=null && email_table!=undefined){
$.ajax({
url:'....',
success: function(data) {
data.split(',').forEach(function(email){
email_table.append('<tr><th>'+email+'</th><th><input type="button" name="'+email+'" value="X">');
});
}
});
}
});
该程序仅适用于我刷新页面,如果我不重新加载页面程序不起作用。
查看控制台以获取更多信息? –
也许是因为它只存在于'document.ready()'函数中,你有没有想过?真的想想'document.ready()'被调用吗? –
[脚本只在页面重新加载时工作]的完全重复(http://stackoverflow.com/questions/3969144/script-working-only-on-page-reload?rq=1)。你问之前甚至搜索过吗? –