嗨,有这个scipt的人我可以在你选择一个类别或子类别后隐藏它!
如何更改此脚本以隐藏此内容并仅在选择正确的类别或子类别时显示?
<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>
由于
答案 0 :(得分:0)
试试这个:
$('#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>