jquery - 使用 Jquery 触发悬停效果

标签 jquery css internet-explorer google-chrome jsf-1.2

我有两个横幅(图像)每 4 秒切换一次。一张图片可点击,另一张不可点击。下面是代码,

<div class="contentdiv"> 
  <h:commandLink  action="#{myBean.firstBannerClick}" id="firstBanner" style="text-decoration:none;">
  <img src="/firstImage.jpg" width="590" height="210"  border="0" class="clickable"/> 
  </h:commandLink> 
</div>

<div class="contentdiv"> 
    <img src="/secondImage.jpg" width="590" height="210"  border="0" class="notClickable"/> 
</div>

编辑:我也试过下面的代码

$(function(){
    $('.clickable a').hover(function(){
        $(this).css({'cursor':'pointer'});
    },function(){
        $(this).css({'cursor':'default'});
    });
});

$(function(){
    $('.notClickable a').hover(function(){
        $(this).css({'cursor':'default'});
    },function(){
        $(this).css({'cursor':'default'});
    });
});

编辑到此结束

下面是使用的CSS

<style type="text/css">
.clickable
{
cursor: pointer;
}
.clickable a:hover
{
cursor: pointer;
}
.notClickable
{
cursor: default;
}
.notClickable a:HOVER
{
cursor: default;
}

.chrome .clickable
{
cursor: pointer;
}
.chrome .clickable a:hover
{
cursor: pointer;
}
.chrome .notClickable
{
cursor: default;
}
.chrome .notClickable a:HOVER
{
cursor: default;
}
</style>

当图像切换时,当用户将光标移到图像上时,第一个图像将显示为指针。当第二个图像发生切换时,并且当用户没有将光标从图像上移开时,第二个图像也将显示为指针而不是默认值。只有当用户将光标移到第二张图片上时,它才会更改为默认,然后用户就会知道第二张图片不可点击。

这个问题在FF上没有看到。然而,这是在 Chrome 和 IE 中看到的。

这个问题可以看作是this one的延续.由于现在问题是特定于浏览器的,所以我将其作为一个新问题提出。

最佳答案

您可以像这样手动更改鼠标光标:

// Changes the cursor to an hourglass
function cursor_wait() {
    document.body.style.cursor = 'wait';
}

// Returns the cursor to the default pointer
function cursor_clear() {
    document.body.style.cursor = 'default';
}

关于jquery - 使用 Jquery 触发悬停效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13909888/

相关文章:

css - Safari 和 FF 的奇数缩放级别中动画 Sprite 的亚像素问题

java - Javaee 中的 SSL/TLS 协议(protocol)版本

internet-explorer - 无法在 IE8 开发者工具中设置 "Always Refresh from Server"

javascript - jquery按钮点击变化闪烁然后熄灭

javascript - jQuery 中的嵌套 2D 表,将 TD 附加到 TR

jQuery - 如果有两个类 - 获取第一个

javascript - 有没有办法只禁用一个 div 的微小滚动?

css - 列表编号和列表内容的不同字体

css - SVG 堆叠元素颜色重叠

html - 元素在 Chrome/Firefox 和 Internet Explorer 中呈现不同