+ 3
Why would someone use DOM document methods in javascript ?
If I wanted to select an img element and change its src into a different directory, wouldn't it be best to just go to that img element and change it rather than adding extra JS code that is just going to patch things up - getelementbyid("src")
4 Réponses
+ 7
If you wanted to make a gallery with images that change their sources every 4 seconds what would you do? You would do it with your finger? ~_~
+ 2
Basicaly, JS is used for make 'dynamic' changes on a page, without reloading a new version.
The DOM is the data structre which manage the document content and provide a link between the display and the script: code modify the DOM, and the DOM request the display handler ( browser ) for updating the view...
0
Yes you can change the image itself and it's a solution in general :) ... but if you want this image in some cases to be another one for example we can say imagr for the sun at day and want it to be replaced to the moon at night so adding javascript code now is important and will handle this logic.
0
to dynamically perform manipulation of documents rather than manual manipulation.