select用js设置选中的

直接上代码

function display(optionID){
            var all_options = document.getElementById("SFLX2").options;
            for (i=0; i<all_options.length; i++){
                if (all_options[i].id == optionID)  // 根据option标签的ID来进行判断  测试的代码这里是两个等号
                {
                    all_options[i].selected = true;
                }

            }

        };
        display(“3”);

 

posted @ 2020-02-06 18:53  武向前  阅读(4967)  评论(0)    收藏  举报