How to check if a checkbox is checked in jQuery?
Hello everyone! I'm a beginner in JavaScript and jQuery, and I've run into a seemingly simple task that I just can't solve.
I have an HTML form with a checkbox:
```html
```
I need to check, when the button is clicked, whether this checkbox is checked. If yes — show an alert with the message "Agreed", if not — "Not agreed".
I've tried tons of solutions from the internet. I tried using `$('#myCheckbox').val()`, `$('#myCheckbox').attr('checked')`, `$('#myCheckbox').prop('checked')` — but the result is always weird. Sometimes it always returns `undefined`, sometimes `true` even when I uncheck it, and sometimes it just outputs the string "on".
Here's my