jquery .click overriding anchor href when i dont want it to!

前端 未结 4 993
孤城傲影
孤城傲影 2021-01-26 11:13

I have a set of nested DIVs that slidetoggle using jQuery as the user clicks on them. Inside the innermost DIV there is an anchor tag with an HREF that should navigate somewhere

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-26 11:18

    Your problem is return false; which is blocking the default behavior.

    $("a:eq(0)").click(function() {
        return false; /* does nothing */
    });
    $("a:eq(1)").click(function() {
        /* go to href */
    });
    
    • Example on jsFiddle

提交回复
热议问题