简体   繁体   中英

Stop Calling Div Function on click of anchor tag inside it

<div onclick="fnOne()">
  <a href="#" data-target="#div2">text</a>
</div>

Now On Click of anchor tag fnOne() is also calling. #div2 data-target also working. Now how to prevent calling fnOne() on click of anchor tag and show only div2.

How about this one:

<div class="click">
  <a href="#" data-target="#div2">text</a>
</div>

$('.click').on('click',function(e){
e.stopImmediatePropagation();
/*call your function*/
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM