由于某度众所周知的举动,让我搬离写了5年的渣度空间,准备把技术性的文章定在CSDN了。这些都是文章备份。勿怪。。
纠结啊。老是忘了操作select的东西。。还是写下来吧
js:
获取id为 select_list 下拉列表 值和文本:
l=document.getElementById("select_list");
文本: l.options[l.selectedIndex].text
值: l.options[l.selectedIndex].value
添加一个option:
l.options.add(new Option("text","value"))
删除选中的option
l.options.remove( l.selectedIndex );
jquery:
$('#select_list option:selected').text();
$('#select_list option:selected').val();
遍历下拉列表查找某个值
$("select").each(
function()
{
if($this().val()=="xxx")//
{ //做点什么 }
if($this().text()=="xxx")
{ //、做点什么}
//弹出选中值
alert($(this).children('option:selected').val())
}
(未完)