make a user script that changes every 'href' attribute of every element - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:attr

Description

make a user script that changes every 'href' attribute of every element

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/* w  w  w.j  a va 2  s .c  o  m*/
$("[href]").attr("href", "http://java2s.com");
    });

      </script> 
 </head> 
 <body> 
  <p> Test text <a href="http://stackoverflow.com">link</a> </p>  
 </body>
</html>

Related Tutorials