这里的spnPrev是怎么获取到DOM元素的?

既没有调用原生DOM选择器也没有调用jquery选择器。。直接用id就能获取dom了吗?疑惑

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>微调按钮插件</title>
        <link href="http://www.imooc.com/data/jquery-ui.css" rel="stylesheet" type="text/css" />
        <link href="style.css" rel="stylesheet" type="text/css" />
        <script src="http://www.imooc.com/data/jquery-1.8.2.min.js" type="text/javascript"></script>
        <script src="http://www.imooc.com/data/jquery-ui-1.9.2.min.js" type="text/javascript"></script>
    </head>
    
    <body>
        <div id="divtest">
            <div class="title">
                选择颜色值</div>
            <div class="content">
                <span id="spnColor" class="input fl">
                    <input />
                </span>
                <span id="spnPrev" class="prev fr"></span>
            </div>
        </div>
        
        <script type="text/javascript">
            $(function () {
                //定义变量
                var intR = 0, intG = 0, intB = 0, strColor;
                $('input').spinner({
                    //初始化插件
                    max: 10,
                    min: 0,
                    //设置微调按钮递增/递减事件
                    spin: function (event, ui) {
                        if (ui.value == 8)
                            spnPrev.style.backgroundColor = "red";
                        else
                            spnPrev.style.backgroundColor = "green";
                    },
                    //设置微调按钮值改变事件
                    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";
                    }
                });
            });
        </script>
    </body>
</html>

尼康老法丝
浏览 1230回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP