Jquery select by attribute name and loop each this value append text - Javascript jQuery Selector

Javascript examples for jQuery Selector:attribute value

Description

Jquery select by attribute name and loop each this value append text

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-1.8.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//  w  ww .  j  ava 2  s  .  com
$('a[icon]').each(function(){
   $(this).before('<span>'+$(this).attr('icon')+'</span>')
});
    });

      </script> 
 </head> 
 <body> 
  <a href="#" icon="http://www.java2s.com/style/demo/Firefox.png">link</a> 
  <a href="#" icon="http://www.java2s.com/style/demo/Firefox.png">link</a> 
  <a href="#" icon="http://www.java2s.com/style/demo/Opera.png">link</a>  
 </body>
</html>

Related Tutorials