3

I change the content of a metatag like this:

$('meta[name=myMeta]').attr('content', 'newContent');

this works and

console.log($('meta[name=myMeta]').attr('content'));

resonses me the 'newContent'

but if i now click "View Sourcode" i cant see the changes i made with jquery.

Can i solve this some how?

  • The dynamic changed won't be displayed if you view the source code as far as i know. Try inspecting the `DOM` instead. – T J Aug 08 '14 at 08:32

2 Answers2

3

Viewing the source code in the browser shows the HTML as it was downloaded from the server.

To see amendments you have made to the DOM after the page has loaded, you need to use a DOM inspector, usually available by pressing F12.

Rory McCrossan
  • 306,214
  • 37
  • 269
  • 303
  • :D oh haha thx i always thought viewsourcode and F12 are showing the same code ^^ That was really helpfull thx guys – user3789173 Aug 08 '14 at 08:51
1

You are confusing the source of a page with the DOM.

The source is the original content delivered from the server, it will not change.

The DOM is live version of the source, this can be changed by javascript. In Chrome you can view this by right clicking on a page and selecting 'Inspect Element'.

ilivewithian
  • 18,642
  • 19
  • 93
  • 158