Created
June 26, 2022 09:40
-
-
Save edib/d345090a8d414ca02bf502fd84eca362 to your computer and use it in GitHub Desktop.
This file contains 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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script> | |
$(function() { | |
$('#appear_text').hide(); | |
// bind change event to select | |
$('#dynamic_select').on('change', function() { | |
var url = $(this).val(); // get selected value | |
var text = $( "#dynamic_select option:selected" ).text(); | |
if (url) { // require a URL | |
// window.location = url; // redirect | |
console.log(text); | |
$('#appear_text').text(text); | |
$('#appear_text').show(); | |
} | |
return false; | |
}); | |
}); | |
</script> | |
<!-- language: lang-html --> | |
<div style="float:left;"> | |
<select id="dynamic_select"> | |
<option value="" selected>Pick a Website</option> | |
<option value="http://www.google.com">Google</option> | |
<option value="http://www.youtube.com">YouTube</option> | |
<option value="https://www.gurustop.net">GuruStop.NET</option> | |
</select> | |
</div> | |
<div id="appear_text"> | |
text | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment