-4

Can you guys plz tell me how I can change this image into clickable image? Actually it's a call to action HTML code, when someone clicks the button then image is shown, but I want to show clickable Image. How can I do that?

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Tesco JSONP</title>

    <script type="text/javascript">

        function picture(){ 
        var pic = "http://img.tesco.com/Groceries/pi/118/5000175411118/IDShot_90x90.jpg"
        document.getElementById('bigpic').src = pic.replace('90x90', '225x225');
        document.getElementById('bigpic').style.display='block';

        }


    </script>


</head>

<body>


        <img id="bigpic" src="bigpic" style="display:none;" />

    <button onclick="picture()">Enlarge</button>

</body>

</html>

http://jsfiddle.net/eX5kx/

  • You can attach another `onclick` handler on the `img` element and write another function like `picture()` which would do what you want. Hope this is a good starting point, if you are unsure how to achieve this, I recommend you go through a few tutorials and come back to edit the question with where you got stuck. – Tomáš Hübelbauer Jan 12 '19 at 19:03
  • hi.thanks but i cant understand what you say can you please correct my html code – Numair Awan Jan 12 '19 at 23:31

1 Answers1

0

Add an onclick handler to your img element:

<img id="bigpic" src="bigpic" style="display:none;" onclick="alert('clickable')" />

The next step is to know what you want your click action to be. We can't help you with that, but you are welcome to ask another SO question as long as it is clear and properly researched, showing what you have tried and explaining where you got stuck.

Tomáš Hübelbauer
  • 9,179
  • 14
  • 63
  • 125