Created
October 4, 2018 19:59
-
-
Save acbrent25/3f88fee76a521f71b73ee4c92ea208e8 to your computer and use it in GitHub Desktop.
Link to another page on select option change using jQuery
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
<div class="column-select" id="select-url"> | |
<select> | |
<option selected>View All Projects</option> | |
<option value="https://sample-url-1.com">Sample URL 1</option> | |
<option value="https://sample-url-2.com">Sample URL 2</option> | |
<option value="https://sample-url-3.com">Sample URL 3</option> | |
</select> | |
</div> |
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
jQuery(function($){ | |
// Get the URL Div | |
$('#select-url').on('change', function(){ | |
// Set the selected option as a variable | |
var url = $(this).find(':selected').val(); | |
// if has value send to that url | |
if(url){ | |
window.location = url; | |
} | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment