HTML页面勾选框赋值


html页面代码


  
  

    
  

  

    

      
        
        
      

    

    

      
        
        
       

    

  

JS代码

var $leibei = $('.client-type').parent();
$leibei.each(function () {
  var id = $(this).find('input').attr('id');
  var pid = $(this).find('.client-type').attr('id');
  if (item[id]) {
    var arr = item[id].split(',');
    $.each(arr, function (i, v) {
      $('#' + pid).find('.weui-icon-circle').each(function () {
        if ($(this).attr('data-type') === v) {
          $(this).addClass("selected");
        }
      })
    });
  }
});
item接口返回对象
页面显示