Javascript OnChange for Checkbox

I have 5 checkboxes and 1 textarea in my form and would like to just hook OnChange() for all of these. However, for whatever reason nothing I have found on Stack Overflow seems to be getting called.

As this is the most basic example I found, what is wrong with this?

  • Enter triggers button click
  • Add basic data to a Google Spreadsheet via a simple HTML Form
  • this.form.submit() not working after clicking div element in form
  • how to write javascript code inside php
  • JQuery - Form Submit - Many times?
  • Angular update html from another section
  • <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"/>
    <script type="text/javascript">
    $(document).ready(function()
    {
        $("input").on("input", function()
        {
            alert("CHANGED");
        });
    }
    </script>
    

  • Change value of input then submit form in javascript
  • Javascript Common Tasks Form Library
  • How do I append a url typed into a input text field to an anchor then follow it when anchor is clicked?
  • JavaScript form validation with PHP not sending emails
  • How to continuously update a part of the page
  • input field: limit the number of letters and numbers typed
  • 5 Solutions collect form web for “Javascript OnChange for Checkbox”

    The oninput event is only triggered when the text of an input changes, so it won’t be fired for checkboxes. Try binding to the change event for checkboxes and the input event on textareas:

    $("textarea").on("input", yourFunction);
    $("input:checkbox").on("change", yourFunction);
    
    function yourFunction() {
        alert("CHANGED");
    }
    

    jsFiddle which demonstrates the above.

    Note: The difference in this answer is the alert is triggered immediately in the textarea, not only on blur of the element.

    Additional Note: The oninput event isn’t supported in < IE9

    you should handle change event:

    $('input:checkbox,textarea').change(function () {
       alert('changed');
    });
    

    Why you bind input event for checkbox, it’s only fire for textarea?

    You need to bind change event :

    Try this one:

    Updated

    $(document).ready(function()
    {
        $("textarea").on("input", function(){
          alert("CHANGED");
        });
    
        $("input").on("change", function(){
            alert("CHANGED");
        });
    });
    

    Try in fiddle

    Checkboxes usually used with same name property so in selector name property will be usefull

    $("input[name='interests']").change(function(){
       /*some code*/
    });
    

    It will not work on textarea . you can assign all radio button and textarea a same class and then

    $(".your_class_name").on("change", function()
    {
        alert("CHANGED");
    });