jquery判断ListBox某个值是否存在 本帖最后由 wzcxm 于 2013-09-30 12:09:41 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(function(){ alert($("select").find("option[value='a']").length); //非0就是找到了 alert($("select").find("option[value='d']").length); //0是没找到 }); </script> </head> <body><select id="s"><option value="a">a</option><option value="b">b</option><option value="c">c</option></select> </body></html> 我已近搞定了,谢谢各位大神 function isExist(listbox,id) { if(listbox!=null&&listbox.options.length) { for(var i=0;i<listbox.options.length;i++) { if(id==listbox.options[i].id) { return true; } } } return false; } 鼠标移上去出现浮动层 一款不错的日历控件 谁会用JS制作电子地图呀 去年写的一个可编辑的下拉框 如何把目标页面填充到指定div中 求Javascript和Design Pattern都比较熟悉的朋友 请问我怎么判断一个对象是不是已经被建立,可以用typeOf吗? JAVASCRIPT如何能中断程序 各位老鸟,请问怎么用脚本修改注册表阿! 麻烦把这个PHP文件转换成JS。 关于jquery操作TreeView的问题 请问qq空间的音乐播放器是怎么做的?没有使用flash。
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
alert($("select").find("option[value='a']").length); //非0就是找到了
alert($("select").find("option[value='d']").length); //0是没找到
});
</script>
</head>
<body>
<select id="s">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
</body>
</html>
function isExist(listbox,id)
{
if(listbox!=null&&listbox.options.length)
{
for(var i=0;i<listbox.options.length;i++)
{
if(id==listbox.options[i].id)
{
return true;
}
}
}
return false;
}