<select>的<option>框的jQuery选择器

FFi*_*ish 19 jquery jquery-selectors

鉴于下面的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
});
Run Code Online (Sandbox Code Playgroud)

Pee*_*Haa 28

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