Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<select>
</select>
<script>
 data=  [
        {
            "id": "all",
            "text": "All",
            "children": [
                {
                    "id": "item1",
                    "text": "item1"
                },
                {
                    "id": "item2",
                    "text": "item2"
                }
            ]
        }
    ];
$('select').select2({"data":data});
$('select').select2("val",["item2"]);
</script>
</body>
</html>
Output

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

Dismiss x
public
Bin info
saidbakrpro
0viewers