0
How to Write a JS Code to remove all img Tags from HTML Page
5 Réponses
+ 6
var images = document.getElementsByTagName('img');
var l = images.length; for (var i = 0; i < l; i++) {
images[0].parentNode.removeChild(images[0]); }
+ 2
var imgTags=document.querySelectorAll('img') ;
for(let i=0;i<imgTags.length;i++) {
document.body.removeChild(imgTags[i]) ;
}
0
// fist select all img tags
const imgs = document.querySelectorAll("img") ;
// start a loop
imgs.forEach(each => {
// to remove every
let parent = each.parentElement;
//now remove it
parent.removeChild(each);
}) ;
0
Can anyone please send me the code to just remove all <a href="......">
?