[英]Show fieldset based on category script
Hi guys with this scipt i can hide it after you select a category or subcategory! 大家好,您可以在选择一个类别或子类别后将其隐藏!
How to change this script to hide this in first and only show when selected the right category or subcategory? 如何更改此脚本以使其首先隐藏并且仅在选择了正确的类别或子类别后才显示?
<script type="text/javascript">
$('#catId').change(function(){
if( $('#catId').val() == "2" || $('#catId').val() == "3" || $('#catId').val() == "46" || $('#catId').val() == "48")
{
$("#indoor-specifications").hide(); // change Posted By with ID you give to the div
}else
{
$("#indoor-specifications").show(); // change Posted By with ID you give to the div
}
});
</script>
Thanks 谢谢
Try this: 尝试这个:
$('#catId').on('change', function() { var optionSelected = $("option:selected", this); var valueSelected = this.value; if( (valueSelected == "2") || (valueSelected == "3") || (valueSelected == "46") || (valueSelected == "48")){ $("#indoor-specifications").hide(); } else{ $("#indoor-specifications").show(); } })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select id="catId"> <option value="2">One</option> <option value="3">Two</option> <option value="5">Five</option> <option value="6">Six</option> </select> <br /> <div id="indoor-specifications">Hello World</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.