Селектор jQuery для окна <select> <option>

Учитывая HTML ниже, мне нужен селектор jQuery, который выбирает <option> с классом with-stamp.

<select name="preset_select">
    <option selected="selected" value="original">ORIGINAL</option>
    <option value="large">LARGE</option>
    <option class="with-stamp" value="medium">MEDIUM</option>
</select>

$("select[name=preset_select]").change(function() {
    // console.log( $(this).hasClass("with-stamp") ); // all false
    // console.log( $("select[name=preset_select] option").hasClass("with-stamp") ); // all true
});

Ответы

Ответ 1

$("select[name='preset_select']").change(function() {
    $(this).children(':selected').hasClass('with-timestamp')
}

Ответ 2

Вам нужно проверить только :selected <option> (так как .hasClass() возвращает true, если какой-либо из элементов в наборе имеет класс), например:

$("select[name=preset_select] option:selected").hasClass("with-stamp")

Ответ 3

$("select[name=preset_select] option:selected").hasClass('with-stamp').change(function() { 

});