Why is it that javascript can make changes to the DOM, but those changes

The Awaken

New member
I know what you mean. The thing is that the JavaScript is the source.

The DOM is referring to the things on screen, which are essentially programming objects that are manipulated to HTML source.

If you were to change the source code dynamically, there would be no way to find out what it originally was.
 
aren't reflected in HTML source? I get that javascript is client-side, so that the server serves up the HTML to the browser, and then the browser runs the javascript against it, but it seems odd that you don't see any DOM changes when you view the source. For example, if you have basic <a href> links, and you use javascript to add dynamic ids or titles, that doesn't show in the source, even though the changes exist in the DOM.
 
That's because the HTML code is separate from javascript. I don't understand your question, because the two things are completely independent. A .html file may contain javascript inside it or make reference to a separate .js file, but nothing is going to change the source at all. That's already set.
 
Because when you view the source, you view the source — not a serialization of the current DOM.

Firebug ( http://getfirebug.com/ ) can show you the current DOM.
 
Back
Top