jQuery checkbox event handling

后端 未结 7 843
借酒劲吻你
借酒劲吻你 2020-11-29 16:30

I have the following:

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 17:11

    Acknowledging the fact that the asker specifically requested jQuery and that the answer selected is correct, it should be noted that this problem doesn't actually need jQuery per say. If one desires to solve this problem without it, one can simply set the onClick attribute of the checkboxes that he or she wants to add additional functionality to, like so:

    HTML:

    
      
      
    
    

    javascript:

    function cbChanged(checkboxElem) {
      if (checkboxElem.checked) {
        // Do something special
      } else {
        // Do something else
      }
    }
    

    Fiddle: http://jsfiddle.net/Y9f66/1/

提交回复
热议问题