This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
1
Getting text from option
Post Body
I have a select tag I'm trying to get the text of the option I am clicking on because I want to use the text to execute some tasks:
my html file:
<select name="ciao" id="yui_3_17_2_1_1631285726939_22">
<option id="search" value="search" name="search">Giulia Totti</option>
<option id="search" value="search" name="search">annalisa costa</option>
<option id=" search" value="search" name="search">Isidoro Tricarico</option>
<option id="search" value="search" name="search">Carmela Maria
Graziano</option>
<option id="search" value="search" name="search">Chiara Dra</option>
<option id="search" value="search" name="search">Tommaso Condello</option>
<option id="search" value="search" name="search">Andrea Leoni</option>
<option id="search" value="search" name="search">Giulia Totti</option>
<option id="search" value="search" name="search">Adnan Al Aghawani</option>
<option id="search" value="search" name="search">Chiara Dra</option>
<option id="search" value="search" name="search">Serena Fossati</option>
</select>
my JS file:
function init() {
var me = $(this);
var meIndex = me.index();
$('select').click(function() {
console.log($('option').text());
})
}
$(document).ready(init);
**I also tried**
function init() {
var me = $(this);
var meIndex = me.index();
me.click(function() {
console.log(me.text());
})
}
$(document).ready(init);
what 'Im getting wrong?
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/moodle/comm...