i have been struggling getting following code work (example taken jsfiddle after looking @ responses in forum.
can see i'm going wrong?
<script type="text/javascript"> var checkboxes = $("input[type='checkbox']"), submitbutt = $("input[type='submit']"); checkboxes.click(function() { submitbutt.attr("disabled", !checkboxes.is(":checked")); }); </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script> <h1>button should enabled if @ least 1 checkbox checked</h1> <form> <div> <input type="checkbox" name="option-1" id="option-1"> <label for="option-1">option 1</label> </div> <div> <input type="checkbox" name="option-2" id="option-2"> <label for="option-2">option 2</label> </div> <div> <input type="checkbox" name="option-3" id="option-3"> <label for="option-3">option 3</label> </div> <div> <input type="checkbox" name="option-4" id="option-4"> <label for="option-4">option 4</label> </div> <div> <input type="checkbox" name="option-5" id="option-5"> <label for="option-5">option 5</label> </div> <div> <input type="submit" value="do thing" disabled> </div> </form>
Comments
Post a Comment