Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  
<script src="http://ivaynberg.github.io/select2/select2-3.4.5/select2.js?ts=2014-02-03T15%3A41%3A41-08%3A00"></script>  
  
      <link href="http://ivaynberg.github.io/select2/select2-3.4.5/select2.css?ts=2014-02-03T15%3A41%3A41-08%3A00" rel="stylesheet"/>
  
        <link href=" http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"/>
 
  
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  
 
 <select id="sel" style="width: 100%">
    <option value="1">Hello</option>
    <option value="2">Friends</option>
    <option value="3">Stackoverflow</option>
</select>
<br><br>
<button id="addok">Add OK <i class='fa fa-check'></i></button>
  
 
  
</body>
</html>
 
$(document).ready(function () {
$("#sel").select2();
    
    $("#addok").click(function() {
      $("#sel").select2({
          //formatResult: format
          formatSelection: format
          //escapeMarkup: function(m) { return m; }
      });
    });
});
function format(state) {
    if (!state.id) return state.text; 
    return "<i class='fa fa-check'></i>" + state.text;
}
Output

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

Dismiss x
public
Bin info
holmes2136pro
0viewers