如何在jquery中将div元素的visible属性设置为true或false?

时间:2021-03-16 22:50:47

I would like to be able to do this:

我希望能够这样做:

$(".panel").visible = true;

but this doesnt work

但这不起作用

3 个解决方案

#1


65  

For the display CSS property, use .show(), .hide() or .toggle() to affect whether it displays, like this:

对于显示CSS属性,使用.show(),. hide()或.toggle()来影响它是否显示,如下所示:

$(".panel").show();
//or to hide:
$(".panel").hide();
//toggle show/hide
$(".panel").toggle();
//or show/hide based on boolean:
$(".panel").toggle(bool);

For the visibility CSS property, you need to set it manually (jQuery is mostly built around display), using .css() like this:

对于可见性CSS属性,您需要手动设置它(jQuery主要围绕显示构建),使用.css(),如下所示:

$(".panel").css("visibility", "visible");
//or:
$(".panel").css({ visibility: "visible"});

#2


3  

For me this worked:

对我来说,这工作:

document.getElementById('my_elementid').style.visibility='visible';

#3


0  

you can by using ClientScript on serverside call your jquery method

您可以通过在服务器端使用ClientScript调用您的jquery方法

ClientScript.RegisterStartupScript(this.GetType(), "hideslidertab", "hideslidertab();", true);

#1


65  

For the display CSS property, use .show(), .hide() or .toggle() to affect whether it displays, like this:

对于显示CSS属性,使用.show(),. hide()或.toggle()来影响它是否显示,如下所示:

$(".panel").show();
//or to hide:
$(".panel").hide();
//toggle show/hide
$(".panel").toggle();
//or show/hide based on boolean:
$(".panel").toggle(bool);

For the visibility CSS property, you need to set it manually (jQuery is mostly built around display), using .css() like this:

对于可见性CSS属性,您需要手动设置它(jQuery主要围绕显示构建),使用.css(),如下所示:

$(".panel").css("visibility", "visible");
//or:
$(".panel").css({ visibility: "visible"});

#2


3  

For me this worked:

对我来说,这工作:

document.getElementById('my_elementid').style.visibility='visible';

#3


0  

you can by using ClientScript on serverside call your jquery method

您可以通过在服务器端使用ClientScript调用您的jquery方法

ClientScript.RegisterStartupScript(this.GetType(), "hideslidertab", "hideslidertab();", true);