jquery 设置 radio

<label id="worksRedio">
	<span style="margin-left: 34px;"><input type="radio" name="works_file_type" value="0" >视频</span>
	<span style="margin-left: 34px;"><input type="radio" name="works_file_type" value="1" checked="checked">文档</span>
</label>

1. 赋值给 radio 并设置成不可选状态(但是能获取radio的value值)

$(":radio[name=‘works_file_type‘][value=‘" + courseWorks.works_file_type + "‘]").prop("checked", "checked"); // 赋值给radio的value$("#worksRedio").click(function(event){
  return false;
});// 获取值并设置选中状态后其他radio按钮不可选

2.赋值 radio 后设置成禁用状态

$(":radio[name=‘works_file_type‘][value=‘" + courseWorks.works_file_type + "‘]").prop("checked", "checked"); // 赋值给radio的value$("input:radio[name=‘works_file_type‘]").attr(‘disabled‘,true); // 禁用状态

 

原文地址:https://www.cnblogs.com/bb1008/p/9467857.html

时间: 2024-07-31 10:25:49

jquery 设置 radio的相关文章

jquery 设置radio状态checked ,IE6、7 不兼容问题

设置radio为选中状态: $("#ownId").attr("checked",true); 但此方法在IE6.IE7下不起作用.在网上搜索了很多解决方案,无果. 现找到一个简易的方法解决该问题.原来IE6.IE7下控制选中状态的属性为“defaultChecked”. 修改代码如下: $("#ownId").attr("checked",true); document.getElementById("ownId&

jquery设置radio选中

<script type="text/javascript"> $(document).ready(function(){ $("input[type=radio][name=sex][value=1]").attr("checked",true); }); </script> 您的性别: <input type="radio" name="sex" value="1

JQuery 设置checkbox select radio 为“只读”

JQuery  设置checkbox select radio 为“只读”,通过测试知道使用HTML标签的 text 和 textarea .button 可以设置readonly="readonly"属性. 但是checkbox .select. radio 这三个控件使用起来不能使用readonly="readonly"属性,只有 disabled="disabled"可以使用. 这样就出现问题了.又想不让修改,又想在后台获取值.如果使用di

jquery 根据值设置radio选中状态

radio选中 $("input[name=test][value=34]").attr("checked",true);//value=34的radio被选中 $("input[id=testid][value=34]").attr("checked",true);//value=34的radio被选中 jquery 根据值设置radio选中状态

jQuery设置 select、radio、checkbox 默认选中的值

[javascript] view plain copy <!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> <m

jquery获取和设置radio,check,select选项

select控件选项 1,获取select选中的value值 $("#selectID").val(); 2,获取select选中的text的值 $("#selectID").find("option:selected").text() 3,设置select的第几项为当前选中项 $("#selectID").attr("value",2);//设置第二项为当前选中项 4,添加option $("s

jquery设定radio的checked无效

环境:chrome + jquery.2.1.1.min.js 设置一次为checked的状态后,再一次设置radio状态,无效. 如: $('input[type="radio"][name="name"]').attr("checked", "checked"); $('input[type="radio"][name="name"]').attr("checked&quo

使用jQuery设置disabled属性与移除disabled属性

Readonly只针对input和textarea有效,而disabled对于所有的表单元素都有效,下面为大家介绍下使用jQuery设置disabled属性 表单中readOnly和disabled的区别: Readonly只针对input(text/ password)和textarea有效,而disabled对于所有的表单元素都有效,包括select,radio, checkbox, button等. 但是表单元素在使用了disabled后,当我们将表单以POST或GET的方式提交的话,这个

jQuery设置和获取HTML、文本和值

jQuery设置和获取HTML.文本和值 按 Ctrl+C 复制代码 <script type="text/javascript"> //<![CDATA[ $(function(){ //获取<p>元素的HTML代码 $("input:eq(0)").click(function(){ alert( $("p").html() ); }); //获取<p>元素的文本 $("input:eq(1