Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <p id="hello">Hello World</p>
</body>
</html>
 
var text = '<select name="test">\
<option value="blah">one</option>\
<option value="mehh">two</option>\
<option value="rawr">three</option>\
</select>';
function extractOptions(html) {
  var el = document.createElement('div'),
      result = [], select, option;
  el.innerHTML = html; // inject html
  select = el.getElementsByTagName('select')[0];
  for (var i = 0, n = select.options.length; i < n; i++) {
    option = select.options[i];
    result.push({value: option.value, text: option.innerHTML});
  }
  return result;
}
var options = extractOptions(text);
for (var i = 0; i < options.length; i++) {
  alert('value:' + options[i].value + '\ntext:' + options[i].text);
}
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers