2012-12-17 43 views
0

我有兩個橫幅(圖像),其保持每4秒切換懸停效果。一個圖像可點擊,另一個則不可以。下面是代碼,觸發使用jQuery

<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> 

當圖像切換,第一圖象會時,他在圖像上移動他的鼠標指針顯示爲指向用戶。當交換機發生第2幅圖像,當用戶還沒有移動他的鼠標指針從圖片上移開,第二圖像也將顯示爲指針,而不是默認。只有當用戶移動他的第二個圖像上的光標,它會改變爲默認值,然後用戶會知道,第2圖像無法點擊。

這個問題是沒有看到FF。而這在Chrome和IE中可見一斑。

這個問題可以被看作是this one延續。因爲,現在這個問題是特定於瀏覽器的,所以我把它作爲一個新的提出來。

回答

0

您可以手動更改鼠標光標這樣的:

// 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'; 
} 
+0

當觸發cursor_wait()和cursor_clear()函數? –

+0

內部.hover()用於任何「一個」元件,使用一個變量來檢查按鈕的狀態。 – ATOzTOA