2012-03-15 94 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