Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
<script src="https://code.jquery.com/jquery-2.0.3.js"></script>
  
  <title>JS Bin</title>
</head>
<body>
<select onchange="test(this)" >
   <option id="fake" value="fake"></option>
   <option value="value1">option 1</option>
   <option value="value2">option 2</option>
</select>
</body>
</html>
 
var fake = $('#fake').hide();
function test(selectTag){
   var selectedOption = $( "select option:selected" );
   var selectedValue = selectTag.value;
   // Do you thing with selected value.
  // For example, log it out
  console.log('selectedValue', selectedValue);
  // Set the text of the fake value 
  fake.text(selectedOption.text());
  // And select it. Note that the fake tag itself is still hidden
  selectTag.value = 'fake';
}
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers