My div is not redirecting using jQuery

后端 未结 2 470
余生分开走
余生分开走 2021-01-16 22:23

Using jQuery from here: http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js

$(\".myBox\").click(function(){
    window.location=$(this).attr(\"h         


        
相关标签:
2条回答
  • 2021-01-16 22:27

    What TurnItUp posted above should work as well but here you go, the JQuery approach:

    $(".mybox").click(function(){
        $(location).attr('href','http://www.google.com');
    });
    

    I also assume that you're wrapping it under "document ready event", correct ?

    Full thing should really be

    $(function()
    {
       $(".mybox").click(function(){
           $(location).attr('href','http://www.google.com');
       });
    });
    
    0 讨论(0)
  • 2021-01-16 22:47

    Use like this:

    window.location.href = "http://www.google.com";
    
    0 讨论(0)
提交回复
热议问题