js怎么判断下拉框值选中的值是否改变?

解决方案 »

  1.   

    在onchange里给一个全局变量flag赋值为true,button按钮的onclick事件显示就可以了嘛。。
      

  2.   

    <!DOCTYPE html>  
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <title>无标题文档</title>
    </head>  
      
    <body>  
    <select id="select">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    <button id="button">button</button>
    <script>
    var selector = document.getElementById('select'),
    index = selector.selectedIndex;
    button = document.getElementById('button');
    button.onclick = function(){
    var _index = selector.selectedIndex;
    if(_index !== index){
    index = _index;
    alert('change');
    }else{
    alert('no change');
    }
    }
    </script>
    </body>  
    </html>  
      

  3.   

    是啊 ie确定买不了。我在chrome跑不了
      

  4.   

    var selector = document.getElementById('select'),
                index = selector.selectedIndex,
                button = document.getElementById('button');
            button.onclick = function(){
                var _index = selector.selectedIndex;
                if(_index !== index){
                    index = _index;
                    alert('change');
                }else{
                    alert('no change');
                }
            }纯属手误,一个,号误打成;号了,话说你们都不会调试下么。。
      

  5.   

    var selector = document.getElementById('select'),
                index = selector.selectedIndex,
                button = document.getElementById('button');
            button.onclick = function(){
                var _index = selector.selectedIndex;
                if(_index !== index){
                    index = _index;
                    alert('change');
                }else{
                    alert('no change');
                }
            }纯属手误,一个,号误打成;号了,话说你们都不会调试下么。。不能修改回复,这是什么狗屁设定。。