需要对 DOM / Missing 元素有更好的了解。
我用
$(document).ready(function(){
// show div tag
});
但我似乎被我的元素在 DOM 中以某种方式不可用的困扰。
console.log($(".show_quota").length);
console.log($(".show_restriction").length);
两个长度都是 0。所以这些 div 标签在我的 DOM 中不可用。
那么我必须寻找什么?如何在 DOM 中获取这些元素?知道为什么这些 html 表单元素会从 DOM 中消失吗?
不$(document).ready(function()
确保所有 html 元素都出现在 dom 中?只要在jquery中正确调用了class和id?
更新 1:安装了 Mozilla DOM Inspector - 但被信息淹没了 :)
但是,嘿...查看良好的旧源 html(通过 Inspect Element With Firebug)和 div 标签不显示...所以...难怪 jquery 命令不起作用。
更新 2: html 标记通过以下方式处理;
$('#modal').html("");
var output = '<div class="modal-content">';
output += 'some html stuff';
output += '<div id="show_quota" >';
output += 'some html stuff 2';
output += '</div>';
$('#modal').append(output);
$('#modal').reveal();
更新 3:问题已解决;
经过;
- 卸载 FireQuery(我的设置中的 Buggy)
修改的
output += '<div id="show_quota" >'; // to line below output += '<div id="show_quota" style="display:inline" >';
这些使标签在单击复选框时出现/消失。