[PROG] what's up with appendChild
|
Author |
Message |
Tetris999
..............................
Posts: 2,390.4622 Threads: 298
Joined: 15th Apr 2007
Reputation: -6.7936
E-Pigs: 82.5657
|
[PROG] what's up with appendChild
I was just doing a little messing around with javascript and I got onto the topic of inserting nodes into the DOM. Basically, I used appendChild on the body element, appending a p element. Thing is, when you view the source of the page, the source page doesn't register that a p element was added to the page, yet you can clearly see a paragraph element on the display page. Why is that? It's confusing since you can't tell if your element was successfully added or not.
I'm guessing that it has something to do with the page being loaded first and the script being second.
Here's the code/page
MY SIG IS FUCKING DEAD
|
|
02/08/2012 08:35 AM |
|
S7*
Sweet Dreams
Posts: 16,689.4373 Threads: 1,056
Joined: 3rd Apr 2007
Reputation: 14.29926
E-Pigs: 383.2309
|
RE: [PROG] what's up with appendChild
Yes you're right. Viewing the source file will show you the page your browser downloaded.
Use a proper DOM inspector which will show you the page as you see it - most browsers have them integrated now, just hit F12.
|
|
02/08/2012 09:40 AM |
|
User(s) browsing this thread: 1 Guest(s)