简体   繁体   中英

How do I prevent default tab switching functionality in JQuery?

I have created the tabs below.

<ul class="idTabs">
<li><a href="#basic_info" id="basic_info_link" >Personal</a></li>
<li><a href="#add_info" id="add_info_link">Address</a></li>
<li style="width:194px;"><a href="#payment_info" id="payment_link" style="border-left:none;width:194px;">Bank</a></li>
</ul>
<div id="basic_info"><!--HTML Code --></div>
<div id="add_info"><!--HTML Code --></div>
<div id="payment_info"><!--HTML Code --></div>

The tabs work fine, but the problem is that on clicking these tabs heading I want to prevent to go to next tab.

$('.idTabs li a').on('click', function(e) {

   e.preventDefault();

});

DEMO

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