我有一个<select>
元素数量可变的页面(这解释了为什么我在这里使用事件委托)。当用户更改所选选项时,我想隐藏/显示页面上的不同内容区域。这是我的代码:
$(document).ready(function() {
$('#container').change(function(e) {
var changed = $(e.target);
if (changed.is('select[name="mySelectName"]')) {
// Test the selected option and hide/show different content areas.
}
});
});
这适用于 Firefox 和 Safari,但在 IE 中不会触发更改事件。有谁知道为什么?谢谢!