2012-03-15 128 views
0

我使用的代碼看起來像這樣:增加HTML5範圍按鈕

<label for="htop">Top: </label><input type="range" name="htop" id="htop" value="0" min="0" max="2" /> 

我想添加一個按鈕,將通過1每按一次增加範圍的值。有沒有一個好的方法來做到這一點?

回答

0

使用jQuery,你可以做到這一點。

$('button#increase').click(function(){ 
    var range = $('input#htop'); 
    range.attr('max', parseInt(range.attr('max')) + 1); 
}); 

假設你有一個按鈕,increase

http://jquery.com/

+0

我使用jQuery的ID。我會在哪裏添加這個腳本。我試圖將它添加到標題,但它沒有奏效。 – AquaMorph 2012-03-15 02:54:25