Last active
December 11, 2015 04:38
-
-
Save tusharvikky/4546365 to your computer and use it in GitHub Desktop.
Friend Requests: This gist will fetch the value of the select and will log it in console.
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
<!-- Author: @tusharvikky --> | |
<!-- Created: 16th Jan 2013 --> | |
<html> | |
<head> | |
<title>Grab select value</title> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
$("#button").click(function(e){ | |
e.preventDefault(); // This is just to prevent re submitting of form again as default jquery. | |
//console.log("button clicked"); | |
var selected_value = $("#op1").val(); | |
console.log(selected_value); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<form action="" id="id"> | |
<select id="op1"> | |
<option value="one">abc</option> | |
<option value="two">pqr</option> | |
<option value="three">xyz</option> | |
</select> | |
<button id="button" type="submit">Button</button> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment