kampfkuchen
kampfkuchen

Reputation: 484

How to turn picture into link in jquery?

<script>
        $(function() {
            var BV = new $.BigVideo();
            BV.init();
            if (Modernizr.touch) {
                BV.show('/pics/googlePlusCover.jpg');
            } else {
                BV.show('/video.mp4',{ambient:true});
            }
        });

</script>     

I am trying to make this BV.show('/pics/googlePlusCover.jpg'); a clickable link. Unfortunately I do not know how!
I am sure this is an easy task for somebody, who is more in the know.

Thank you so much for your help already!!

Upvotes: 2

Views: 1234

Answers (1)

Gaurang Tandon
Gaurang Tandon

Reputation: 6753

If you have an image, say:

<img src="http://placehold.it/400x400" />

use:

$("img").wrap("<a href='http://www.google.com'></a>")

which will wrap the image inside <a> elements, and make it a link. If there are multiple of them, use wrapAll.

DEMO

Upvotes: 1

Related Questions