<!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-3.5.1.min.js"></script> <script> $(document).ready(function () { $("#btn1").click(function () { $("img").attr({ "class": "frame", "title": "Dog" }); }); $("#btn2").click(function () { var ss = $("img").attr(["alt", "src"]); alert(ss.src + " , " + ss.alt); }); }); </script> <style> .frame{ border: 10px solid blue; } </style> </head> <body> <button id="btn1" type="button">Set Attributes for Image</button> <button id="btn2" type="button">Get Attributes for Image</button> <p> <img src="examples/resources/dog.jpg" alt="Dog"> </p> </body> </html>