user1800105
user1800105

Reputation: 75

Removing an element

An element is removed from the html file with the following code,

$("#sample").remove();

When view the source code, the removed element still appear in the source code. Whether it is possible to remove the element from the source code?

Upvotes: 1

Views: 385

Answers (3)

Rob Breidecker
Rob Breidecker

Reputation: 604

The source code is static. It is simply the code that was used to load the page. Modifying the DOM does will NOT affect the source code. Just as adding to the DOM will also NOT add to the source code.

Upvotes: 1

Aamir Shahzad
Aamir Shahzad

Reputation: 6834

i will agree with Adil, it's not possible through the scripting language i.e. javascript/jquery...

$("#sample").empty();
//will not work...

Upvotes: 0

Adil
Adil

Reputation: 148120

It is not possible to remove element from source control using script on client like javascript. It is removed from DOM and wont participate in rendering and wont be accessible through script.

Upvotes: 5

Related Questions