vendredi 9 décembre 2016

Jquery checkbox check/uncheck issue

This is something I could not figure out.

<input type="checkbox" id="ckbox1" onclick="getFunc(1)" />

<input type="checkbox" id="ckbox2" onclick="getFunc(2)" />

The JS

getFunc(val){
        if($("#ckbox"+val).attr('checked',true)){
        lock_arr.push({"name":val});
        }
        else{
        lock_arr.pop({"name":val});
  }
}

What I want is that the lock_arr should populate an array of object if all are checked. If a checkbox is unchecked than the array would pop the uncheck value and occupy with only the checked value.

Any help would be appreciated




Aucun commentaire:

Enregistrer un commentaire