Codepedia
.info
Home
About
Demos
Tools
SVG Wave Generator
Colors
Edit This Code :
<html> <head> <body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> Example 1: <select id="example1"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> <option value="4">four</option> </select>Example 2 : <select id="example2"> <option id="1">one</option> <option id="2">two</option> <option id="3">three</option> <option id="4">four</option> </select> <script> $(document).ready(function() { $("#example1").on('change', function () { alert($(this).val()); }); $("#example2").on('change', function () { //alert($(this).val()); alert($(this).find('option:selected').attr('id')); }); }); </script> </body> </html>
➤ Run / View
Result :