Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get children of element using javascript

how can i use Javascript, not jQuery, to get all images inside of a certain element. I need to be getting them by tag as well.

Also im looking for that images that get effected by

#container img

not

#container > img

Thanks, Luke :).

like image 875
Luke Pring Avatar asked Oct 18 '13 10:10

Luke Pring


2 Answers

try this:

var cont = document.getElementById("container");
var all_img = cont.getElementsByTagName('img');
like image 119
webduvet Avatar answered Sep 27 '22 19:09

webduvet


You can use document.getElementById("#container").children;

like image 27
S. S. Rawat Avatar answered Sep 27 '22 19:09

S. S. Rawat