Javascript jQuery隐藏和切换

Javascript jQuery隐藏和切换,javascript,jquery,html,toggle,Javascript,Jquery,Html,Toggle,我有多行文章,里面有。文章行,里面有。内容,然后单击。文章行。当前jQuery将找到.content,然后将其切换。但是我想更改代码,使其.hide()与单击的内容不相关的.content的所有实例 $('.article-row').click(function(){ $(this).parent().find('.content').toggle(); }); 隐藏所有元素,然后显示单击的元素。但是,首先要确认点击的文章是否已经不是活动的,以确保在设置过渡动画时,它不会闪烁或看

我有多行
文章
,里面有
。文章行
,里面有
。内容
,然后单击
。文章行
。当前jQuery将找到
.content
,然后将其切换。但是我想更改代码,使其
.hide()
与单击的内容不相关的
.content
的所有实例

$('.article-row').click(function(){
    $(this).parent().find('.content').toggle();
});


隐藏所有元素,然后显示单击的元素。但是,首先要确认点击的文章是否已经不是活动的,以确保在设置过渡动画时,它不会闪烁或看起来很奇怪。

这样做不会更干净吗

            $('.article-row').click(function(){
                if($(this).parent().find('.content').is(':visible')){
                    $('.content').hide();
                }else{
                    $('.content').hide();
                    $(this).parent().find('.content').show();
                }
            });
$('article.entry').on('click', '.article-row', function () {
    $(this).siblings('.content').show();
    $('.content').hide();
});
            $('.article-row').click(function(){
                if($(this).parent().find('.content').is(':visible')){
                    $('.content').hide();
                }else{
                    $('.content').hide();
                    $(this).parent().find('.content').show();
                }
            });
$('article.entry').on('click', '.article-row', function () {
    $(this).siblings('.content').show();
    $('.content').hide();
});