在html中,我们根据id为type的select控件值的变化,动态变化business,city,district的显示情况。
在table中控制tr的显示与隐藏时,不要用$(".business").css(display, "block"),这样会使tr的显示出现问题,用hide和show即可。
$("#type").change(function(){
var type = $("#type option:selected").val();
if(type=="0"){
$(".business").hide();
}
if( type=="1"){
$(".business").hide();
$(".province").show();
}
if( type=="2"){
$(".business").hide();
$(".city").show();
}
if( type=="3"){
$(".business").hide();
$(".district").show();
}
if( type=="4"){
$(".business").show();
}
});
本文介绍如何在HTML中通过改变特定选择器的值,动态控制business、city、district等元素的显示与隐藏,避免使用不合适的CSS方法导致的问题。

1657

被折叠的 条评论
为什么被折叠?



