简体   繁体   English

单击时,jquery ui禁用的选项卡带有链接

[英]jquery ui disabled tabs following link when clicked

I just noticed that when I click on the disabled jquery ui tab, it follows the link which I do not want. 我只是注意到,当我单击禁用的jQuery ui选项卡时,它遵循了我不需要的链接。

The code is like this, 代码是这样的,

var $tabs = '<div id="layer-tabs">'+
                '<ul>'+
                    '<li><a href="#layer-1"><span>1</span></a></li>'+
                    '<li><a href="#layer-2"><span>2</span></a></li>'+
                    '<li><a href="#layer-3"><span>3</span></a></li>'+
                '</ul>'+
                '<div id="layer-1"> </div>'+
                '<div id="layer-2"> </div>'+
                '<div id="layer-3"> </div>'+
            '</div>';

$( "#tabs-parent" ).append( tabs );

$("#tabs").tabs({ heightStyle: "fill", disabled : [0,1,2] });

Lets say your location is this file:///C:/Users/user/website/index.html, and you click the first diabled tab, it brings you to this, file:///C:/Users/user/website/index.html/#layer-0 . 假设您的位置是这个文件:/// C:/Users/user/website/index.html,然后单击第一个禁用选项卡,它将带您到这里,文件:/// C:/ Users / user / website / index.html /#layer-0。 How do I stop this from happening? 如何阻止这种情况的发生?

只需对带有禁用类的选项卡使用preventDefault即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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