i’m trying to run a function after checkbox checked and pushed submit button with jquery
this is what i have:
<form name="select">
<label for="Genre"><input type="checkbox" checked="checked" id="Genre">Genre</label>
<input type="button" onclick="myFunction()" value="submit">
</form>
this is my function:
function myFunction() {
$("input [id=Genre] [checked]").each(
function() {
alert("genre is checked");
}
);
}
any ideas what i’m doing wrong?
If you select by ID you can just use:
If you want to select all checkboxes then you can just:
If you want to select a checked checkbox you can use:
If you want to do something WHEN someone checks a checkbox you need to add an event listener: