Been trying for hours, but can't get this to work.
If I go direct
$(.button).click(function(event){
var graham = window.document.childNodes[1].childNodes[2].childNodes[1].childNodes[9];
$(graham).css('color', 'red');
)};
But instead of just typing out the DOM node directly, if I cycle it through a loop like:
$(.button).click(function(event) { js = (js.slice(0, -1)).split(","); for(x = 0; x< js.length; x++) { js[x] = "childNodes[" + js[x] + "]"; } js = "window.document." + js.join("."); $(js).css('color', 'red');
)};
Nothing happens onclick. Is there something wrong with using 'window.document' as a string and appending it to the childNodes data? I thought this would be straight forward, but can't get it to work!..