tags:

views:

44

answers:

1

i am trying to do something like this in jquery.

if ($(e.target) == "select"){
//var output = $(e.target).each option

//display newoverlay(output)
}
+1  A: 

How about:

if($(e.target).is('select')) {
    $('option', e.target).each(function() {
        /* "this" is the <option> element in here */
        // newoverlay(this)
    })
}

Although I'm not sure what you want to do with the individual <option> elements.

Roatin Marth
i need to output the text content of option.
aoghq
also how do you distinguish from select-single and select-multiple ? i would need to only isolate single select drop down.
aoghq
@aoghq: use the `.text` property to get the text for the `<option>`. Re your other comment, do you mean how would you get the selected options? If so you'd just change the selector from `'option'` to `'option:selected'`.
Roatin Marth