1
我能够在stackoverflow上找到一个示例来执行我想要的操作。然而,当我在我的代码中实现它,并选择将显示一个隐藏的div的选项时,隐藏的div不会出现并且不知道为什么。当选择或取消选择特定的下拉选项时,切换隐藏的div
HTML:
CSS:
/*Simple Dropdown box*/
.selectmenu{
font-family: arial, sans-serif, tahoma;
-webkit-appearance: none; /*Removes default chrome and safari style*/
-moz-appearance: none; /* Removes Default Firefox style*/
background: white;
width: 80px; /*Width of select dropdown to give space for arrow image*/
text-indent: 0.01px; /* Removes default arrow from firefox*/
text-overflow: ""; /*Removes default arrow from firefox*/ /*My custom style for fonts*/
color: black;
border-radius: 2px;
padding: 5px;
border:0 !important;
box-shadow: inset 0 0 1px rgba(000,000,000, 0.5);
font-size: 1.2em;
}
的Javascript:
$(function() {
$('#select').change(function(){
if ($(this).val() == "3") {
$('#hidden_div').show();
} else {
$('#hidden_div').hide();
}
});
});
您的代码工作正常...请分享小提琴来演示问题... – Rayon