我嘗試通過在下拉菜單中選擇一個選項來切換課程,我嘗試過使用alert()來檢查它是否有效,但我似乎無法使其工作。從下拉菜單中切換課程
HTML:
<html>
<body>
<select id="dropdown">
<option value="1">Steinkjer</option>
<option value="2">Verdal</option>
</select>
</body>
</html>
的Javascript:
$('#dropdown option:selected').click(function(){
var getText = $('#dropdown option').text();
alert($('.overlay-'+getText));
});
請幫我解決這個問題。
(」 #dropdown選項:selected「)。text(); – Bugfixer
[jQuery切換div從選擇選項]的可能重複(http://stackoverflow.com/questions/2767284/jquery-toggle-div-from-select-option) – Bugfixer