shubendrak
shubendrak

Reputation: 2068

Why element is not added in the page source

I am trying to add an element using prependTo(). My problem is when is view the source of the page, i don't find the element inside the source. why it is so?

Here is my JsFiddle

$( document ).ready(function() {
$('<option></option>',{value:"newvalue",text:"new option"}).attr({
disabled:"disabled", selected:"selected" }).prependTo("select");
});

Upvotes: 3

Views: 52

Answers (1)

6502
6502

Reputation: 114579

The "show source" option of browsers can only show what was the source of the page at the time it was downloaded.

If you add elements or alter in other ways the DOM after loading by using Javascript the changes will not be visible in that view. To see the current state of the page (and even to alter it) you can use the "inspect elements" option instead.

Upvotes: 7

Related Questions