Avatar ·

How to get selected text from a dropdown list (select) using jQuery?

Hello everyone! I'm a beginner in JavaScript and jQuery, and I'm having a problem working with dropdown lists. I have a regular HTML select with several options: ```html ``` I want that when an item is selected, the console displays not the value (1, 2, 3), but the text of the option — "Apple", "Pear" or "Banana". I tried using `$('#mySelect').val()`, but it only returns the value attribute. I tried something like `$('#mySelect option:selected').text()` — but it didn't work, it returns an empty string. What am I doing wrong? I need it specifically in jQuery, since this library is already included in the project. Thanks in advance for your help! P.S. I would like