jquery遍历select元素(实例讲解)
2023-06-13 09:15:15 时间
本篇文章提供一款jquery遍历select教程代码,主要是利用了$("#<%=ddl_xreg_id.clientid%>option").each(function(){形式来each遍历一次,这样所有的select就给查询了一次。
<scriptsrc="jquery-1.2.1.js"type="text/网页特效"></script>
<scriptlanguage="javascript"type="text/javascript">
$(document).ready(function(){
$("#selecttest").change(function()
{
//alert("hello");
//alert($("#selecttest").attr("name"));
//$("a").attr("href","xx.html");
//window.location.href="xx.html";
//alert($("#selecttest").val());
alert($("#selecttestoption[@selected]").text());
$("#selecttest").attr("value","2");
});
});
</script>
<ahref="#">aaass</a>
<!--下拉框-->
<selectid="selecttest"name="selecttest">
<optionvalue="1">11</option>
<optionvalue="2">22</option>
<optionvalue="3">33</option>
<optionvalue="4">44</option>
<optionvalue="5">55</option>
<optionvalue="6">66</option>
</select>
方法二
functionautoscrollregion(){
varreg_name=$("#<%=txt_reg_name.clientid%>").val();
$("#<%=ddl_xreg_id.clientid%>option").each(function(){
if($(this).text()==reg_name){
$(this).attr("selected","selected");
break;
}
});
}
相关文章
- 简述vue和jquery的区别「建议收藏」
- jquery监听input值改变事件详解编程语言
- jquery.post用法详解编程语言
- jQuery中文入门指南,翻译加实例,jQuery的起点教程
- JQuery中getJSON的使用方法
- jquery异步请求实例代码
- JQuery循环滚动图片代码
- jquery$.getJSON()跨域请求
- JQuery获取各种宽度、高度(format函数)实例
- 7款吸引人眼球的jQuery/CSS3特效实例分享
- jquery设置元素相对于另一个元素的top值(实例代码)
- jQuery处理xml格式的返回数据(实例解析)
- 制作jquery遮罩层效果导航菜单代码分享
- jQuery判断checkbox(复选框)是否被选中以及全选、反选实现代码
- jquery实现弹出层完美居中效果
- jquery插件开发之实现md5插件
- 使用Jquery获取带特殊符号的ID标签的方法
- jQuery遍历之next()、nextAll()方法使用实例
- jQuery提示效果代码分享
- js与jQuery实现的兼容多浏览器Ajax请求实例
- jquery实现显示已选用户
- 基于Jquery+Ajax+Json实现分页显示附效果图
- jquery通过ajax加载一段文本内容的方法
- jQuery元素的隐藏与显示实例
- JQuery动画与特效实例分析