Javascript JQuery";“变灰”;在表单中输出文本字段
我有以下功能,但当单选按钮选择为“否”时,它不会模糊。你知道为什么吗 表单元素:Javascript JQuery";“变灰”;在表单中输出文本字段,javascript,jquery,html,Javascript,Jquery,Html,我有以下功能,但当单选按钮选择为“否”时,它不会模糊。你知道为什么吗 表单元素: <td> Email: Yes? <input type="radio" name="emailquest" value="true" checked> No? <input type="radio" name="emailquest" value="false"> </td> <td> <input type="text"
<td>
Email: Yes? <input type="radio" name="emailquest" value="true" checked>
No? <input type="radio" name="emailquest" value="false">
</td>
<td>
<input type="text" name="email">
</td>
电子邮件:是吗?
不
脚本:
<script>
$(document).ready(function(){
$("#emailquest").blur(function(){
if ($(this).val() != true)
$("#email").attr("disabled","disabled");
else
$("#email").removeAttr("disabled");
});
});
</script>
$(文档).ready(函数(){
$(“#emailquest”).blur(函数(){
if($(this).val()!=true)
$(“电子邮件”).attr(“禁用”、“禁用”);
其他的
$(“#email”).removeAttr(“禁用”);
});
});
正如波蒂所说,#
用于ID,而不是名称
$("input[name='emailquest']").change(function(){
if (this.value != "true") { // <----I would probably change this to look for this.checked
$("input[name='email']").prop("disabled", true);
} else {
$("input[name='email']").prop("disabled", false);
}
});
正如波蒂所说,#
用于ID,而不是名称
$("input[name='emailquest']").change(function(){
if (this.value != "true") { // <----I would probably change this to look for this.checked
$("input[name='email']").prop("disabled", true);
} else {
$("input[name='email']").prop("disabled", false);
}
});
#
在选择器中用于按id而不是按名称选择元素。您使用的是什么版本的jQuery?()更改$(this.val()!=true
到$(this).is(':checked')
@kevinb1.9.1就是我想要的using@elavarasanlee.attr()
不会贬值,只是不再更新属性。#
在选择器中用于按id而不是按名称选择元素。您使用的是什么版本的jQuery?()更改$(this.val()!=true
到$(this).is(':checked')
@kevinb1.9.1就是我想要的using@elavarasanlee.attr()
不会贬值,只是不再更新属性。您可以使用=
比较作为.prop()
的第二个参数,并去掉复选框:checked
的if
语句:-),但在这种情况下,他需要识别选中内容的值,而不是它是否选中…因为你不能取消选中单选按钮,价值更大important@tymeJV谢谢你的帮助!工作得很好+1您可以使用=
比较作为.prop()
的第二个参数,并去掉复选框:checked
的if
语句:-),但在这种情况下,他需要识别选中内容的值,而不是它是否选中…因为你不能取消选中单选按钮,价值更大important@tymeJV谢谢你的帮助!工作得很好+1.