Run ยป
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> </head> <body> <select id="myselect"> <option value="1">One</option> <option value="2">Two</option> <option selected value="3">Three</option> <option value="4">Four</option> <option value="5">Five</option> </select> <script> $(document).ready(function(){ var valSelected = $("#myselect option:selected").val(); var textSelected = $("#myselect option:selected").text(); alert(valSelected); alert(textSelected); }); </script> </body> </html>