获取select、radio、checkbox的value值以及文本框值
2012-12-23 18:27
337 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> 获取被选中的radio值</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <script src="js/jquery-1.7.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("#test").click(function(){ $(":input[type='checkbox']:checked").each(function(){ //获取被选中的checkbox的value值 alert($(this).val()); }) var docTemp=document.thisform.checkbox; for (i=0;i <docTemp.length;i++){ if(docTemp[i].checked){ strText=docTemp[i].nextSibling.nodeValue; // 获取被选中的checkbox的文本值 alert(strText); } } alert($(":radio:checked + span").text()); //获取被选中的radio 文本值 alert($(":input[type='radio']:checked").val()); //获取被选中的radio value值 alert($("#select_id").val()); // 获取被选中的 select的value值 alert($("#select_id").find("option:selected").text()); // 获取被选中的 select的文本值 }) }) </script> </head> <body> <form name="thisform" method="post"> 你爱国吗: <input type="radio" name="radio1" class="rd" id="rd" value="1"/> <span>a</span> <input type="radio" name="radio1"class="rd" id="tt" value="2" /> <span>b</span> <input type="radio"name="radio1"class="rd" value="3"/> <span>c</span> <ul id="options" class="options"> <li><label for="opA" ><input type="checkbox" name="checkbox" id="opA" value="1"/>选项A</label></li> <li><label for="opB" ><input type="checkbox" name="checkbox" id="opB" value="2" />选项B</label></li> <li><label for="opC" ><input type="checkbox" name="checkbox" id="opC" value="3"/>选项C</label></li> <li><label for="opD" id="op"><input type="checkbox" name="checkbox" id="opD" value="4"/>选项D</label></li> </ul> <select id="select_id"> <option value="111">aa</option> <option value="222">bb</option> <option value="333">cc</option> </select> <input type="button" value="test" id="test"/> </form> </body> </html>
相关文章推荐
- JQUERY 获取form表单text,areatext,radio,checkbox,select值 以及 JavaScrpt获取文本框值
- 使用 Jquery 选中获取 checkbox radio 和 select的 value 和 text
- jQuery获取form中Select/textarea/checkbox/radio选择的Text和Value等其他常见操作
- jquery获取指定表格的指定列的值 以及 操作radio,checkbox,select表单操作实现代码
- jQuery获取Radio,CheckBox选择的Value值
- Jquery 获取表单text,areatext,radio,checkbox,select值的代码
- Jquery 获取表单text,areatext,radio,checkbox,select值的代码
- jquery获取和设置radio,select,checkbox的值
- js_前台页面如何设置radio、checkbox、select三者的值以及绑定事件,方便后台接收数据
- JQUERY获取text,areatext,radio,checkbox,select值
- JQUERY获取form表单text,areatext,radio,checkbox,select值
- Jquery获取radio,checkbox,select的值
- jquery中,radio与select及checkBox标签选中及未选中和获取值得方法
- Extjs练习——服务器端获取信息填充客户端表单,注意Radio以及Checkbox值的传递
- JQUERY获取text,areatext,radio,checkbox,select值
- jQuery 根据ID,获取input/checkbox/radio/select
- js获取下拉列表选中项的值和文本(select)以及获取单选按钮(radio)组的值和修改选中项[转]
- js获取下拉列表选中项的值和文本(select)以及获取单选按钮(radio)组的值和修改选中项[转]
- jquery取得text,areatext,radio,checkbox,select的值,以及其他一些操作
- 使用JQuery获取被选中的checkbox的value值 以及全选、反选