jQuery:如果我的 css 可见性:隐藏,我该如何显示我的元素?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4387940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 17:11:55  来源:igfitidea点击:

jQuery: if my css visibility:hidden, how can i appear my elements?

jqueryvisibilityopacity

提问by davidino

in my css i've set some elements visibiliy:hidden, how can I show them?

在我的 css 中,我设置了一些元素 visibiliy:hidden,我该如何显示它们?

I've done it before with opacity, but i've some bug in IE:

我以前用不透明度做过,但我在 IE 中有一些错误:

var i = 0;
$mySelection.each(function(i) {
    $(this).delay((i * 100) + ($mySelection.length)).animate(
        { opacity: "1"},
        {queue:true, duration:1000, easing:"quartEaseIn"}
    ); 
})

How can i do if I want controll visibility with jQuery instead of opacity? thank you

如果我想用 jQuery 而不是不透明度来控制可见性,我该怎么办?谢谢你

回答by karim79

$(":hidden").css("visibility", "visible");

回答by cspolton

Rather than using visibility: hidden, use display:none, then if you want to fade in your hidden element use fadeIn. For example:

而不是使用visibility: hidden,使用display:none,然后如果你想淡入你的隐藏元素使用fadeIn。例如:

$("div:hidden").fadeIn("slow");

Edit:Given that you want to use visibility, try this:

编辑:鉴于您想使用可见性,请尝试以下操作:

var i = 0;
$mySelection.each(function(i) {
    $(this).delay((i * 100) + ($mySelection.length)).css(
        { 'opacity': '0', 'visibility': 'visible'}).animate(
            { opacity: "1"},
            {queue:true, duration:1000, easing:"quartEaseIn"});
});

回答by JasoBeam 777

I used this code to change the CSS visibility attribute with Jquery. Where the element1 on hover will change visibility of element2.

我使用此代码通过 Jquery 更改 CSS 可见性属性。悬停时的 element1 将改变 element2 的可见性。

Did two different script for same element to give a mouseover-mouseleave effect.

为同一个元素做了两个不同的脚本以提供鼠标悬停效果。

 <script>$(document).ready(function(){
 $(".element1").mouseover(function(){
     $(".element2").css("visibility","visible");
 });

});

});

         <script>$(document).ready(function(){
 $(".element1").mouseleave (function(){
     $(".element2").css("visibility","hidden");
 });

});

});

Note.- That Element2 the one thats CSS is being affected, originally is hidden. so when mouse is over Element1, Element2 shows up. When mouse leaves element1, Element2 Hides again. Hope it helps

注意。- 那个 Element2 是 CSS 受到影响的,原来是隐藏的。所以当鼠标悬停在 Element1 上时,Element2 就会出现。当鼠标离开 element1 时,Element2 再次隐藏。希望能帮助到你

-Expiriance of this code reaserching and mixing some other codes from users in stack overflow

-此代码的经验,并在堆栈溢出中混合了用户的一些其他代码

回答by Ives.me

$(':hidden').show();

I hope this helps and I hope I understood your question :) http://api.jquery.com/show/

我希望这有帮助,我希望我理解你的问题:) http://api.jquery.com/show/

回答by rahul

Try

尝试

$mySelection.show();