Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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");
});
like image 498
shubendrak Avatar asked Feb 01 '26 00:02

shubendrak


1 Answers

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.

like image 87
6502 Avatar answered Feb 02 '26 13:02

6502



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!