jquery 显示块/无

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18485803/
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 21:44:34  来源:igfitidea点击:

jquery display block / none

jquery

提问by Md Nadeem

hi as i am new to this jquery could any one help me with this i would like to show the div and hide the dive after trasnsition here is the script

嗨,因为我是这个 jquery 的新手,任何人都可以帮我解决这个问题,我想显示 div 并在转换后隐藏潜水,这里是脚本

jQuery(function($) {

    $('a.panel').click(function() {
        var $target = $($(this).attr('href')),
            $other = $target.siblings('.active'),
            animIn = function () {
                $target.addClass('active').show().css({
                    left: -($target.width())
                }).animate({
                    left: 0
                }, 300);
            };

        if (!$target.hasClass('active') && $other.length > 0) {
            $other.each(function(index, self) {
                var $this = $(this);
                $this.removeClass('active').animate({

                    left: -$this.width()
                }, 300, animIn);
            });
        } else if (!$target.hasClass('active')) {
            animIn();
        }
    });

});

回答by Bhupendra Shukla

If you are using the multiple division (division inside division) in your form then you have to find the id of child div in the parent division like this.

如果您在表单中使用多除法(除法内除法),那么您必须像这样在父除法中找到子 div 的 id。

$("#parentDiv").find("#childDiv").css("display", "block");      
$("#parentDiv").find("#childDiv").css("display", "none");

回答by Vinay Pratap Singh

if using the id for div then

如果将 id 用于 div 那么

$('#dividhere').attr('display','block') //to show
$('#dividhere').attr('display','none') //to hide

if using the class for div then

如果将类用于 div 那么

$('.divclasshere').attr('display','block') //to show
$('.divclasshere').attr('display','none') //to hide

回答by Manu M

Try show and hide in jquery,

尝试在 jquery 中显示和隐藏,

 $('element').show();

 $('element').hide();