2012-05-25 40 views
1

我知道這個問題已被問到,但我無法獲得解決方案的工作。我沒有看到我的圖像。圖像路徑是正確的。我究竟做錯了什麼?如何用我自己的圖像替換jquery滑塊手柄

我讀過解決這個問題:Changing slider handle imageJquery slider with two arrowschanging jquery slider images。第三種解決方案似乎是最好的,但我不知道如何讓這個工作。我已經複製並粘貼,但我無法得到這個工作。下面是完整的代碼:

<!DOCTYPE html> 
<html> 
<head> 
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery- 
ui.css" rel="stylesheet" type="text/css"/> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"> 
</script> 
<script> 
$(window).load(function(){ 
//Used for slider with two arrows - start 
var firstHandleClass = 'first-handle'; 
var secondHandleClass = 'second-handle'; 

handle = $('#slider-range A.ui-slider-handle'); 
handle.removeClass('ui-corner-all'); 
handle.removeClass('ui-slider-handle'); 
handle.addClass('handle_'); 
handle.eq(0).addClass(firstHandleClass); 
handle.eq(1).addClass(secondHandleClass);  

}); 
</script> 
    <script> 
    $(document).ready(function() { 
    $("#slider").slider({ 
range: true, 
values: [5,17] 
}); 
    }); 
    </script> 


    <style type="text/css"> 

    #slider { margin: 10px; } 
.handle_ { 
    cursor: default; 
    position: absolute; 
    top: -0.3em; 
    z-index: 2; 
    } 
.first-handle { 
    background: url("images/lefthandle.gif") no-repeat scroll 0 0 transparent; 
    border-style: none; 
    height: 36px; 
    margin-left: -9px; 
    position: absolute; 
    width: 21px; 
} 
.second-handle { 
    background: url("images/righthandle.gif") no-repeat scroll 0 0 transparent; 
    border-style: none; 
    height: 36px; 
    margin-right: -5px; 
    position: absolute; 
    width: 21px; 
} 
    </style> 

    </head> 
    <body style="font-size:62.5%;"> 

    <div id="slider"></div> 


</body> 
</html> 

enter image description here

下面是截圖。圖像不顯示。任何人?

謝謝。

+0

我看了看螢火代碼和新類'沒有被添加第一handle'廣告'第二handle'。 – Chris22

回答

1

它看起來像選擇器'#slider-range a.ui-slider-handle'不匹配任何元素。試着用'#slider a.ui-slider-handle'替換它,看看是否能解決它,就像這樣:

handle = $('#slider A.ui-slider-handle'); 
handle.removeClass('ui-corner-all'); 
handle.removeClass('ui-slider-handle'); 
handle.addClass('handle_'); 
handle.eq(0).addClass(firstHandleClass); 
handle.eq(1).addClass(secondHandleClass);