removing unwanted tags from html body with jQuery
I have 开发者_StackOverflowinherited some legacy HTML in which it has the following elements in the body of the code:
style
meta
title
How do i remove these with jQuery?
If you can find a proper CSS selector to get to the elements you can simply detach them from the DOM:
$(document).ready(function(){
$('style, meta, title').detach();
});
I highly doubt you really want to detach the <title>
element, though.
$('style, meta, title').remove();
This would remove all of the specified elements from the DOM.
P.S. Make sure this is contained in the $(document).ready()
, as is good practice for most jQuery code you will have to write.
精彩评论