功能:複選框勾選時給input表單賦值,複選框取消時將表單值清除。
實現源碼:cyfID爲複選框的id
html
$("#cyfID").click(function(){ this
var ischeck=$(this).attr("checked");
if(ischeck==undefined){
//清除輸入框
alert("");
}else{
//給輸入框賦值
alert("qq");
} www.jbxue.com
}); spa
實現原理:
複選框勾選時$(this).attr("checked")爲checked,不勾選時爲undefined。htm