JQUERY: get the id's of the checked and not checked checkBox

前端 未结 4 2057
你的背包
你的背包 2020-12-24 14:12

I have this not so many checkboxes:

 
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-24 14:46

    I think I got a shorter version here:

    var idSelector = function() { return this.id; };
    var fruitsGranted = $(":checkbox:checked").map(idSelector).get();
    var fruitsDenied = $(":checkbox:not(:checked)").map(idSelector).get();
    

    You can see it in action here: http://jsfiddle.net/XPMjK/3/

提交回复
热议问题