根据value值 自动选择相应的radio select

radio

$("input[name='  ']").each(function(){
			if($(this).val()==""){
				$(this).attr("checked",true);
			   }
		});

select,  选中值为aa的选项

$("#  ").val("aa");
根据text值设置选中项

一、
$(".selector").find("option[text='pxx']").attr("selected",true);

二、
<pre class="prettyprint lang-js" style="margin-top: 1em; margin-bottom: 1em; padding: 0px 1em; font-family: 宋体; line-height: 21.6px; width: 600px; border-left: 3px solid rgb(204, 204, 204); overflow-x: auto; font-size: 9pt !important; color: rgb(0, 112, 166) !important;">var VZhi=$("#TZhi").val();
$("#S1 option").each(function(i,n){
if($(n).text()==VZhi){
	$(n).attr("selected",true);
}	
});

 

获取当前选中项的value

 $(".selector").val();

获取当前选中项的text

 $(".selector").find("option:selected").text();



select联动

$(".selector1").change(function(){

     // 先清空第二个

      $(".selector2").empty();

     // 实际的应用中,这里的option一般都是用循环生成多个了

      var option = $("<option>").val(1).text("pxx");

      $(".selector2").append(option);

});


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值