简体   繁体   English

CSS Cursor:Pointer不适用于js函数

[英]css cursor:pointer won't work with js function

I wrote a simple tabs module using bootstrap. 我使用引导程序编写了一个简单的选项卡模块。 Here is my code 这是我的代码

<ul id="tabs" class="nav nav-tabs subentry-nav" data-tabs="tabs">
    <li><a href="#red" data-toggle="tab"><h4>Red</h4></a></li>
    <li><a href="#orange" data-toggle="tab"><h4>Orange</h4></a></li>
    <li><a href="#yellow" data-toggle="tab"><h4>Yellow</h4></a></li>
    <li><a href="#green" data-toggle="tab"><h4>Green</h4></a></li>
</ul>

I declared a css style to make the cursor pointer on it. 我声明了一个CSS样式来使光标指向它。

.subentry-nav.nav>li {
    cursor:pointer;
}

It looks fine at this stage. 在此阶段看起来还不错。

Then I tried to make the tab switch on hover instead of on click, so I added this piece of js function: 然后,我尝试使选项卡在悬停而不是单击时切换,因此添加了以下js函数:

$('.nav-tabs > li').hover(function(){
    if($(this).hasClass('hoverblock'))
        return;
    else
        $(this).find('a').tab('show');
})

$('.nav-tabs > li').find('a').click(function(){
    $(this).parent().addClass('hoverblock');
})

After adding this piece of code, the cursor attribute won't work anymore. 添加这段代码后,cursor属性将不再起作用。 Any idea where I did wrong? 知道我做错了什么吗?

It get's overriden by other bootstrap classes which have: 它被其他具有以下内容的引导类覆盖:

.nav-tabs>.active>a, .nav-tabs>.active>a:hover, .nav-tabs>.active>a:focus{
    cursor:default;    
}

One solution whould be to change 一种应该改变的解决方案

.subentry-nav.nav>li {
    cursor:pointer;
}

with

.nav-tabs>.active>a, .nav-tabs>.active>a:hover, .nav-tabs>.active>a:focus{
    cursor:pointer;    
}

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

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