samedi 21 février 2015

target a div in another div javascript


I need to target a div inside another div with javascript (no Jquery, trying to learn raw Javascript first). say I've got a set of 3 divs, called "outerSquare1", "outerSquare2", etc and each has a div inside called "innerSquare" (not numbered).


How can I target the inner square of a particular div at a later point via Javascript. I want to do something like this, but obviously not working.



outerSquare2.innerSquare.style.width="100px";


Or this



foo = outerSquare3.getElementById("innerSquare");
foo.style.width="100px";


JSFiddle





Aucun commentaire:

Enregistrer un commentaire