Created
October 24, 2017 18:02
-
-
Save lucianobragaweb/9c320c4e6dedb13b5a4fae8a41f0463e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action=""> | |
<select class="target"> | |
<option value="option1" selected="selected">Option 1</option> | |
<option value="option2">Option 2</option> | |
</select> | |
<input type="text" id="txt" name="" value=""> | |
</form> | |
<script type="text/javascript"> | |
$( ".target" ).change(function() { | |
var str = ""; | |
$( "select option:selected" ).each(function() { | |
str += $( this ).text() + " "; | |
}); | |
$( "#txt" ).val( str ); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment