select 的js操作

插入元素:

function insertEle(value,text) {
        var obj=$("select[onchange]")[0];
        var newItem = document.createElement("option");
        newItem.text = text;
        newItem.value = value;
        var sel=obj.options[obj.selectedIndex];  
        obj.add(newItem,sel);
    }

设置元素为选中:

 $("option[value=" + jsonResult + "]").attr("selected", "true");

判断某个元素是否为选中:

obj.options[obj.selectedIndex].value=="new"

获取选中的值:

Obj.options[Obj.selectedIndex].value);

 

posted @ 2013-05-06 18:38  瓜王  阅读(168)  评论(0编辑  收藏  举报