简体   繁体   中英

Binding checkboxes to comma separated string in Jquery

I have to bind the checkboxes on a page whose values match in a string containing comma separated values, i have done the opposite of this in jquery through map and join functions. Its a combination of individual checkboxes on the page.

(function(){
  var arr = [4,6,2,7,2];
  for(var i = 0; i < arr.length; i++) {
    $('.checkbox[value=' + arr[i] + ']').prop('checked',true);
  }
})();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM