<script type="text/javascript">
$(function() {
//定义变量
var intR = 0,
intG = 0,
intB = 0,
strColor;
// $("#input").each(function(index) {
// $(this).spinner({
$("input").spinner({
//初始化插件
max: 10,
min: 0,
//设置微调按钮递增/递减事件
spin: function(event, ui) {
if(ui.value == 8)
spnPrev.style.backgroundColor = "red";
else
spnPrev.style.backgroundColor = "green";
//setSpanColor(index, ui.value);
},
//设置微调按钮值改变事件
change: function(event, ui) {
var intTmp = $(this).spinner("value");
if(intTmp < 0) $(this).spinner("value", 0);
if(intTmp > 10) $(this).spinner("value", 10);
if(intTmp == 8)
spnPrev.style.backgroundColor = "red";
else
spnPrev.style.backgroundColor = "green";
//setSpanColor(index, $(this).spinner("value"));
}
});
});
</script>
按钮的html代码是“<span id="spnPrev" class="prev fr"></span>”通过js进行加载