Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
82
rated 0 times [  85] [ 3]  / answers: 1 / hits: 26746  / 12 Years ago, thu, august 30, 2012, 12:00:00

I have this select tag right here



<select id = options style = width:150px;>      
<option>Artist Name</option>
<option>Track Name</option>
<option>Date Uploaded</option>
</select>


I am getting the current selected innerHTML value using JQuery



   var option = $(#options).innerHTML;
console.log(option);


But each time I print it only returns me a value of undefined.


More From » jquery

 Answers
1

You just need:





  $(#options).val();

<script src=https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js></script>
<select id = options style = width:150px;>
<option>Artist Name</option>
<option>Track Name</option>
<option>Date Uploaded</option>
</select>




[#83342] Tuesday, August 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
calicinthias

Total Points: 447
Total Questions: 101
Total Answers: 118

Location: Botswana
Member since Sat, Dec 31, 2022
1 Year ago
calicinthias questions
Sun, Jan 2, 22, 00:00, 2 Years ago
Wed, Jan 13, 21, 00:00, 3 Years ago
Mon, Aug 10, 20, 00:00, 4 Years ago
;