html - jQuery set attribute with .attr() view source not updating -


i new jquery , learning .attr() object method.

i have:

<!doctype html> <html> <head>     <meta charset="utf-8">     <title>demo</title> </head> <body>     <a href="http://jquery.com/">jquery</a>     <script src="jquery-2.1.4.js"></script>     <script>      $(document).ready(function() {          $('a').attr('href', 'http://www.google.com');         console.log( $('a').attr('href') );      });      </script> </body> </html> 

the console return expected value of: http://www.google.com when right click window view source anchor element still: <a href="http://jquery.com/">jquery</a>

why this?

view source shows original source of page when came server.

to view generated/modified source, use developer tools (inspect element)

this case in chrome @ least.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -