我有一个选择列表:
<select id="cd-dropdown" class="cd-select">
<option value="-1" selected>Menu</option>
<option value="http://google.com" class="home">1</option>
<option value="http://google.com" class="home">2</option>
</select>
我还有一个 div,当点击或单击选择列表时(在选项下方),它将覆盖整个屏幕:
<div class="overlay"></div>
Using jQuery I'd like to show/hide this overlay depending on the state the select is in. So if I open the select list, I want the overlay div to fade in and when the select list is closed or an option is selected I '希望叠加层淡出。
我无法让我的 jQuery 工作:
$('#cd-dropdown').onchange( function() {
$( '#overlay' ).toggle.fadeIn();
$( '#overlay' ).toggle.fadeOut();
});