checkbox - checked or unchecked with jquery and mysql

前端 未结 5 1484
清歌不尽
清歌不尽 2020-12-06 11:52

I am currently doing a system where it has to be possible to check/uncheck a checkbox. Everytime it changes status I need jquery to make and ajax call to a page, that update

5条回答
  •  执笔经年
    2020-12-06 12:09

    Detect if checkbox is checked:

    if ( $('#id').is(':checked') ) { }
    

    This can be executed in a function that is triggered by "onchange" event.

    function checkCheckboxState() {
    
        if ( $('#id').is(':checked') ) { 
    
            // execute AJAX request here
    
        }
    }
    

提交回复
热议问题