0
我的表单中有一个复选框。我想在用户选中框之前询问用户。然而,在框勾选后,“确认”消息自动出现。我想让它成为用户可以“取消”的状态,就好像他从未选中过该盒子一样。Jquery:在点击动作之前确认
这里是我的代码:
$(document).ready(function() {
$('.checkme').click(function(){
text_area_id = "#" + $(this).val();
if ($(text_area_id).attr('hidden')) {
$(text_area_id).attr('hidden', false);
} else{
if ($(text_area_id).val() != '') {
if (confirm("Clear text for \'" + $(this).val().replace(/_/g, " ") + "\'?")) {
$(text_area_id).attr('hidden', true);
$(text_area_id).val('');
$(this).attr('checked', true);
$('.checkme').attr('checked', true);
}
} else {
$(text_area_id).attr('hidden', true);
$('.checkme').attr('checked', true);
}
}
});
注 “确认” 对话框。我希望在点击复选框后出现 - 但在盒子实际上被打勾。
所以我想我正在寻找像
.before_click(function(){ ...
,而不是
.click(function(){ ...
或类似的东西一个jQuery函数...?