0

How to Write a JS Code to remove all img Tags from HTML Page

21st Jan 2021, 12:50 PM
Mohammed Azam
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]); }
21st Jan 2021, 12:55 PM
Jamal Saied
Jamal Saied - avatar
+ 2
var imgTags=document.querySelectorAll('img') ; for(let i=0;i<imgTags.length;i++) { document.body.removeChild(imgTags[i]) ; }
21st Jan 2021, 12:53 PM
Abhay
Abhay - avatar
0
Thank You So Much Brother 💞 Jamal and Abhay
21st Jan 2021, 1:44 PM
Mohammed Azam
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); }) ;
21st Jan 2021, 1:55 PM
Krish
Krish - avatar
0
Can anyone please send me the code to just remove all <a href="......"> ?
4th Oct 2021, 3:57 PM
Mohammed Azam