checkbox checkbox, how to let it trigger an event when selected, triggers another event unchecked

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_44037153/article/details/102759804
<input type="checkbox" name="" value="" id="id"/>

$("#id").click(function(){
	if(this.checked){   
		console.log("第一个事件");
	}else{  
		console.log("第二个事件");
	}
})

Guess you like

Origin blog.csdn.net/weixin_44037153/article/details/102759804