Today I want to implement a function: assign a value to the input form when the check box is checked, and clear the form value when the check box is cancelled.
The effect is as shown:
Implementation source code: cyfID is the id of the check box
$("#cyfID").click(function(){
var ischeck=$(this).attr("checked");
if(ischeck==undefined){
//Clear the input box
alert("");
}else{
//Assign a value to the input box
alert("qq" );
}
});
The implementation principle is: $(this).attr("checked") is checked when the check box is checked, and it is checked when it is not checked. undefined.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn