我正在尝试这样做:
<script type="text/javascript">
$(document).ready(function () {
var userType = '<%=Session["UserType"]%>';
if (userType != "Admin") {
alert("Inside If Block");
$("#bodycontent").addClass("hide");
}
else {
}
});
</script>
但是,身体内容并没有隐藏。我正在获取该页面..
请帮助..
如果condditon满意,我试图隐藏页面内容
答案 0 :(得分:1)
您需要在css上定义类隐藏,如:
.hide { display: none; }
或者干脆就这样做:
<script type="text/javascript">
$(document).ready(function () {
var userType = '<%=Session["UserType"]%>';
if (userType != "Admin") {
alert("Inside If Block");
$("#bodycontent").hide();
}
else {
}
});
</script>
答案 1 :(得分:1)
替换
$("#bodycontent").addClass("hide");
带
("#bodycontent").hide();
答案 2 :(得分:0)
试试这个...... 替换
$("#bodycontent").addClass("hide");
与
$("#bodycontent").attr("style","display:none");
...
<script type="text/javascript">
$(document).ready(function () {
var userType = '<%=Session["UserType"]%>';
if (userType != "Admin") {
alert("Inside If Block");
$("#bodycontent").attr("style","display:none");
}
else {
}
});
</script>