Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> img { width: 300px; height: 200px; } </style> <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script> </head> <body> <div class="imgDiv"> <img id="your-image" src="https://ru.w3docs.com/uploads/media/default/0001/05/2c669e35c4c5867094de4bed65034d0cac696df5.png" alt="JS" /> </div> <script> $(document).ready(function() { $("img").click(function() { // Change src attribute of image $("#your-image").attr("src", "https://www.w3docs.com/uploads/media/default/0001/05/9eb9e9cba721ba3bb5e653751449173197f2924a.png"); }); }); </script> </body> </html>