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

前端 未结 4 1027
孤城傲影
孤城傲影 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:23

    you can check the event object of the click and then check the event target - see also http://api.jquery.com/event.target/

     $("div.subSystemHeader, div.subSystemHeader").click(function(event) { 
       if(event.target.nodeName.toLowerCase() == 'a') return;
     ...
     }
    

    (didnt test it, but it should work)

提交回复
热议问题