【发布时间】:2014-05-21 09:21:06
【问题描述】:
鉴于下面的 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
});
【问题讨论】: