Ami*_*mir 0 html javascript checkbox jquery
我有一个带有按钮的复选框,我希望当用户选中复选框并单击按钮显示警报时,如果未选中复选框,用户点击按钮会执行其他操作.
我做了一些事情,但我需要帮助才能完成它.任何帮助非常感谢
$(document).ready(function(e) {
$('#remember').click(function() {
if (this.checked) {
alert("This is checked and you cliked");
} else {
alert("This is unchecked and you cliked");
}
});
});
Run Code Online (Sandbox Code Playgroud)
您可以使用jquery .is()选择器: -
$('input[type="button"]').click(function() {
if ($('#remember').is(':checked')) {
alert("This is checked and you cliked");
} else {
alert("This is unchecked and you cliked");
}
});
Run Code Online (Sandbox Code Playgroud)
您可以将id或class设置为button
$(document).ready(function(e) {
$('#btnEnter').click(function() {
if ($('#remember').is(':checked')) {
alert("This is checked and you cliked");
} else {
alert("This is unchecked and you cliked");
}
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1440 次 |
| 最近记录: |