Jquery Redirect to image src or data-attr

On a image inside link instead of use link href i would like to use img src to redirect to image path.

with this is possible to get the img src but how to use src to redirect? thank's

 $(".drop a").click( function() {
     alert($(this).children('img').attr('src'));
 });

<div class="drop">
<a href""><img src=".." /></a>
</div>

Answers 1

  • Just use window.location

    Code:-

    $(".drop a").click( function() {
    
         window.location = $(this).children('img').attr('src');
         return false;
    });
    

Related Articles