jquery获取radio选中的值或者select做出判断事件

<dl class="clearfix" id="shifou">
                <dt>是否已报名:</dt>
                <dd><input type="radio" name=‘sf‘ value=‘1‘>已报名     <input type="radio" name=‘sf‘ value=‘0‘>未报名(有意向)</dd>
            </dl>
		 <dl class="clearfix">
         <dt>培训机构:</dt>
		 <dd> <select name="jigou" id="jigou">
         <option value="">请选择机构:</option>
         <option value="米乐文化艺术">米乐文化艺术</option>
         <option value="文博教育">文博教育</option>
         <option value="码猿编程教育">码猿编程教育</option>
		 <option value="新爱婴早教中心">新爱婴早教中心</option>
		 <option value="阿木潼">阿木潼</option>
		 <option value="九拍音乐教育">九拍音乐教育</option>
         </select>
		 </dd>
		 </dl>

选择某个按钮修改下面option中的名称;

$("input[name=sf]").each(function(){
        $(this).click(function(){
           if($(this).val()==1)
		   {$("#jigou option:first").text(‘请选择已报名机构‘);}
		   else
		   {$("#jigou option:first").text(‘请选择意向机构‘);
		   }
        });
    });

如果是获取select 或者 radio 选中值,应该这样:

var shifou = $(‘#shifou input[name="sf"]:checked‘).val();
var jigou = $(‘#jigou option:selected‘).val();;

原文地址:https://www.cnblogs.com/weilianguang/p/9052901.html

时间: 2024-07-29 19:45:20

jquery获取radio选中的值或者select做出判断事件的相关文章

Jquery获取radio选中的值

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </ti

jquery获取单选按钮选中的值

在页面上单选按钮的代码: <s:iterator value="@[email protected]"> <input type="radio" <s:if test="key eq record.is_com">checked</s:if> value="${key}" name="record.is_com"/>${value}    </s:ite

jquery 获取下拉框值与select text

下面先介绍了很多jquery获取select属性的方法,同时后面的实例我们讲的是jquery 获取下拉框值与select text代码. 下面先介绍了很多jquery获取select属性的方法,同时后面的实例我们讲的是jquery 获取下拉框值与select text代码. jquery获取select选择的文本与值 获取select : 获取select 选中的 text : $("#ddlregtype").find("option:selected").tex

jQuery获取checkbox选中的值

1.问题背景 有几个多选框,选择其中的几个,获取选中的值 2.设计源码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>

jQuery获取radio选中后的文字

原文链接:http://blog.csdn.net/zhanyouwen/article/details/51393216 jQuery获取radio选中后的文字转载 2016年05月13日 10:32:14 标签:jQuery获取radio选中后的文字 850 HTML 示例如下: [html] view plain copy<input type="radio" id="male" name="sex" value="1&qu

jquery怎么获取radio选中的值

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ

Jquery 获取 radio选中值

Radio 1.获取选中值,三种方法都可以: $('input:radio:checked').val(): $("input[type='radio']:checked").val(); $("input[name='rd']:checked").val(); 2.设置第一个Radio为选中值: $('input:radio:first').attr('checked', 'checked'); 或者 $('input:radio:first').attr('ch

jQuery获取radio选中项的值【转藏】

<title></title> <script src="js/jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(function () { //没有默认选中的情况 //先判断radio是否有选中项,再获取选中的值 $("#btnclick").click(function () { //获取选中项的valu

jquery获取dropdownlist选中的值

var name = $("#DropDownList1 option:selected").val(); //获取dropdownlist 里面选中的值 var name1 = $("#DropDownList1").text(); //获取dropdownlist 里面所用的值 $("#ddl").bind("change", function () {                 alert($("#ddl