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

来源:互联网 发布:java语言程序代码培训 编辑:程序博客网 时间:2024/05/17 00:56

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
原创粉丝点击