jQuery attr()
set multiple attribute for the elements
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Set Multiple Attribute for the Elements</title> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("img").attr({ "class" : "frame", "title" : "Hot Air Balloons" });/* www. ja v a2s . co m*/ }); }); </script> <style> .frame{ border: 6px solid #000; } </style> </head> <body> <button type="button">Set Attributes for Image</button> <p> <img src="/examples/images/myId.jpg" alt="Hot Air Balloons"> </p> </body> </html>