Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Change Image Source on Click in jQuery</title> <style> .card{ margin: 30px; } </style> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $("img").click(function(){ // Change src attribute of image $(this).attr("src", "/examples/images/card-front.jpg"); }); }); </script> </head> <body> <div class="card"> <img src="/examples/images/card-back.jpg" alt="Poker Card"> </div> <p><strong>Note:</strong> Click on the image to change its source.</p> </body> </html>