我想從DOM中刪除元素使用ID一個.remove()不從DOM
HTML
<div id="no-js">
Sorry for the inconvenience<br/>
Your browser does not support javascript or it must be disabled.<br/>
To access the features of our website<br/><br/>
Enable your javascript or upgrade to the browser that supports javascript.
</div>
jQuery的
var x = $("#no-js");
console.log(x.html());
x.remove(); // does not remove the element from dom why?
console.log(x.html()); // it displays html content inside it
console.log(x.length); // results 1
x.empty(); // removes the child elements, working as expected
console.log(x.html()); // html content is empty
console.log(x.length); // length is 1
刪除元素.remove()
似乎沒有按預期工作? 這是小提琴 http://jsfiddle.net/QGsza/14/