samedi 25 avril 2015

Cannot get element by id in Javascript


This code:

onload = function() { document.getElementById('123').classList.add('hidden'); }

does not work... I have this image:

<img src="/img/screenshots/iPhoneMacbook.png" width="100%" id="123">

and Safari shows the error message:

[Error] TypeError: null is not an object (evaluating 'document.getElementById('test').classList')
onload (PlanHW.js, line 5)


Aucun commentaire:

Enregistrer un commentaire