如果我的文本框是空的,我的复选框(Un)被选中,我如何检查这两个选项?
.val('')只会检查我的文本框<input typye="text">是否为空
空值(每两个值合在一起)会有什么作用(typye="text" and typye="checkbox")?
编辑:我的代码这不是空值复选框,输入是包含文本框和复选框:
newDiv.find('input').each(function () { $(this).removeAttr('checked').val(''); }); 发布于 2011-08-09 13:47:07
$('input:text').val('');
$('input:checkbox').removeAttr('checked');若要访问复选框的选中属性:
var isChecked=$('input:checkbox').attr('checked');看看这把小提琴http://jsfiddle.net/7WxzC/
发布于 2011-08-09 13:55:50
试试这个:
//To check whether textbox is empty
if($("input[type=text]").val() == ""){
}
//To check if checkbox is not checked
if(!$("input:checkbox").is(":checked")){
}https://stackoverflow.com/questions/6997096
复制相似问题