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.7.2.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
  <select id="blah">
  <option value="3">Some text 3 </option>
  <option value="4">Some text 4</option>
  <option value="8">Some tex 8</option> // <---- target this tag based on value 7
  <option value="19">Some text 19</option>
</select>
  <br />
  <input type="button" onclick="alert(findClosest(0, $('#blah')));" value="Check For 0"/>
  
  <input type="button" onclick="alert(findClosest(10, $('#blah')));" value="Check For 10"/>
  
  <input type="button" onclick="alert(findClosest(20, $('#blah')));" value="Check For 20"/>
  
</body>
</html>
Output

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

Dismiss x
public
Bin info
Aki143Spro
0viewers