gpt4 book ai didi

javascript - JQuery 不会选择附加的隐藏元素

转载 作者:行者123 更新时间:2023-11-28 04:33:49 25 4
gpt4 key购买 nike

我正在动态添加元素:

$.ajax({
type: "POST",
url: url,
success:function(data) {
$('#trNew').before( data );
}
});

数据:

<tr id="val1">
<td>...</td>
<td><a id="e1" href="#" onclick="return editRow('e1')">Edit</a></td>
<div class="hide" id="popup1">
<input type="text">
<button>Save</button>
</div>
</tr>

被插入到正确的位置。但是,当我尝试选择 $("#popup18")$("#popup18:hidden"),则不会选择任何内容。 document.getElementById("popup1") 也返回 undefined。

有什么我想念的吗?

最佳答案

据我所知,tr 不支持 divs 作为 child

http://www.w3.org/html/wg/drafts/html/master/tabular-data.html#the-tr-element

Zero or more td, th, and script-supporting elements

所以这基本上是无效的 html - 因此什么都行不通 - 取决于今天星星的排列方式

关于javascript - JQuery 不会选择附加的隐藏元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24955117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com