我正在动态添加元素:
$.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/