How can I change image into clickable image?

240 views Asked by At

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/

1

There are 1 answers

0
Tomáš Hübelbauer On

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.