admin管理员组文章数量:1289637
I am aware of .remove() , I am using it and its working fine, I mean its removing the element which I want. But I think it doesn't removes it permanently. On right clicking in browser window selecting View page source I am still able to see those removed elements. I want to remove them pletely or say permanently. Please help.
I am aware of .remove() , I am using it and its working fine, I mean its removing the element which I want. But I think it doesn't removes it permanently. On right clicking in browser window selecting View page source I am still able to see those removed elements. I want to remove them pletely or say permanently. Please help.
Share Improve this question edited Jan 9, 2014 at 13:30 Viks asked Jan 9, 2014 at 13:22 ViksViks 9584 gold badges11 silver badges18 bronze badges 5- 5 It's removed permanently, but "view source" is not an accurate way to check the DOM, it just shows you the original source, you'll need to open the DOM inspector instead. – adeneo Commented Jan 9, 2014 at 13:24
-
I'm not sure by what you mean with permanently. Do you mean you wish to edit the HTML? Because everything you remove with
remove()
will be back once you refresh the page. – timo Commented Jan 9, 2014 at 13:25 - @user3008011: It's fairly clear this is the standard "view source" fallacy. – T.J. Crowder Commented Jan 9, 2014 at 13:25
- You guys are answering fine I am appreciating but why are you rating me down? – Viks Commented Jan 9, 2014 at 13:31
- You might wanna read this link : css-tricks./dom – Karl-André Gagnon Commented Jan 9, 2014 at 13:40
5 Answers
Reset to default 7.remove()
removes them pletely. The reason you still seem then in the view page source is because the page source does not change based on javascript. The page source shows how the page originally looked when it was first loaded, not how it currently is.
If you look in the developers console, you will see that they are no longer there.
Likewise, if you dynamically add a new element with javascript/jquery, it will not show that element in the page source.
Page Source and DOM are two different different things, whenever you edit the elements or remove them it get removes from DOM and not from page source. That means The javascript manipulate the DOM not the source which e from the server.
DOM: The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents.
The view source always shows the content came from the server initially without any modification. Use DEVELOPER CONSOLE in browsers to see the live DOM manipulation.
Note: Press F12 to enable console on major browser
view source render the code within the page that you have written(static)
for dynamic changes/view inspect the elements tab in developer tools.
View page source shows the content of the original HTML file, as returned by the HTTP server. The DOM can be altered with javascript, but the source will not change.
You Cannot permenantly remove the dom elements using jquery or javascript. .remove() is totally different from your logic. just it removes temporary hide from the dom elements suppose you refresh the page it es again it is jquery magic.
本文标签: javascriptDeleting completely a html elementStack Overflow
版权声明:本文标题:javascript - Deleting completely a html element - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741462019a2380091.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论