<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("[img='.jpg']").addClass("intro"); }); </script> <style> .intro { border: 10px solid #000000; } </style> </head> <body> <img src="1.jpg"></a><br> <img src="2.jpg"> </body> </html> But its not working, pls help me...???
1) wrap code inside of the code tags 2) that is because your selector is completely wrong. You should read more about jQuery selectors here: http://api.jquery.com/category/selectors/ 3) proper selector below $("img").addClass("intro"); // If you wanted to do it with just those that end in .jpg $("img[src$='.jpg']").addClass("intro"); Code (markup):
Hi friend.... $("img[src$='.jpg']").addClass("intro"); is not working... can you pls check one... even i tryed $("[src$='.jpg']").addClass("intro"); but no luck