How to add a click function on an image

I am trying to write a function so that when I click on an image it loads external content.

<section class='images'>
<img class="review-img" id="lifeofpi" src="./images/lifeofpi.jpg"></img>
</section>

    $(document).ready(function(){
    $("#lifeofpi").click(function(){
        $("#lifeofpi").load("lifeofpi.txt #p1");
    });
});

When I click on the image I want it to load this external content from a text document. But when I click on the image nothing happens.

Answers 1

Related Articles