我有两个横幅(图像)每 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/