您好,欢迎来到舟格财经。
搜索
您的当前位置:首页jquery遍历select元素(实例讲解)_jquery

jquery遍历select元素(实例讲解)_jquery

来源:舟格财经


本篇文章提供一款jquery遍历select教程代码,主要是利用了$("#<%=ddl_xreg_id.clientid%> option").each(function() {形式来each遍历一次,这样所有的select就给查询了一次。
代码如下:


$(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($("#selecttest option[@selected]").text());
$("#selecttest").attr("value", "2");

});
});


aaass


方法二
function autoscrollregion() {
var reg_name = $("#<%=txt_reg_name.clientid%>").val();

$("#<%=ddl_xreg_id.clientid%> option").each(function() {
if ($(this).text() == reg_name) {
$(this).attr("selected", "selected");
break;
}
});
}

Copyright © 2019- zougedi.com 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务