Javascript examples for jQuery Selector:attribute value
Jquery select by attribute name and loop each this value append text
<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>