Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div>
  <input type='checkbox' data-lid='1'><label>checkbox1</label><br />
    <input type='checkbox' data-lid='2'><label>checkbox2</label><br />
    <input type='checkbox' data-lid='3'><label>checkbox3</label><br />
    <input type='checkbox' data-lid='4'><label>checkbox4</label><br />
</div>
</body>
</html>
 
var arr = ["1", "2"];
var myCBoxes=$('input[type=checkbox]').get().filter(function(el){
  return $.inArray($(el).attr('data-lid'), arr)!=-1;
});
$(myCBoxes).prop('checked','checked');
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers