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/2.0.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
  <select id="opsContactId"></select>
</body>
</html>
 
var obj  = {
  "1":"one",
  "2":"two",
  "3":"three",
  "4":"four"
};
var dept = '2';
$(function () {
  var $sel = $("#opsContactId"); 
  $.each(obj, function (k, v) {
    var $opt = $("<option/>", {value:k, text:v}).appendTo( $sel );
    if (k == dept) $opt.prop({selected:true}); 
  });
  
});
Output

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

Dismiss x
public
Bin info
roXonpro
0viewers