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

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -