js文件
http://jsfiddle.net/JsUWv/4/
$(document).ready(function() {
//set initial state.
$('#textbox1').val($(this).is(':checked'));
$('#checkbox1').change(function() {
if($(this).is(":checked")) {
var returnVal = confirm("Are you sure?");
$(this).attr("checked", returnVal);
}
$('#textbox1').val($(this).is(':checked'));
});
});
html文件
<input type="checkbox" id="checkbox1" /> <br /> <input type="text" id="textbox1" />在线预览
http://jsfiddle.net/JsUWv/4/
转载请注明:谷谷点程序 » jquery checkbox change的使用方法