Manne Moses
Manne Moses

Reputation: 65

On Click Image Doesn't Work

I made a script with an image and a javascript function but it doesn't work. It should redirect to www.moseso.de when you click the image. What's wrong with it?

<html>
    <head>
        <title>Hallo</title>
    </head>
    <body>
        <img src="test.jpg" onclick="func" />
        <script>
            function func() {
                window.location="www.moseso.de"
            }
        </script>
    </body>
</html>

Upvotes: 3

Views: 108

Answers (2)

SWiggels
SWiggels

Reputation: 2296

You can try this:

<img src="test.jpg" alt="" class="img.my_clickable_image" />


<script>
   $(document).ready(function() {
       $('my_clickable_image').click(function() {
           window.location.href = www.moseco.de';
       });
   });
</script>

Upvotes: 0

Evgeny Lukiyanov
Evgeny Lukiyanov

Reputation: 488

try setting:

onclick="func();"

also close the statement:

window.location="www.moseso.de";

Upvotes: 6

Related Questions