简体   繁体   English

使用onclick事件取消隐藏多个元素

[英]Unhide multiple elements with onclick event

I have code working on my site that when someone clicks the content of a row in a table, more content appears. 我的网站上有运行的代码,当有人单击表中行的内容时,会显示更多内容。 That works fine: 很好用:

$(document).ready(function() {
    //hide the all of the element with class abstract
    $("..meetings-list .meeting_title_and_description .abstract").hide();
    //toggle the componenet with class meetingname
    $("..meetings-list .meeting_title_and_description .meeting_name").click(function(){
        $(this).next(".meetings-list .meeting_title_and_description .abstract").slideToggle(50);
     });
});

However, now i want to make a second element to appear as well on the same onclick event. 但是,现在我想让第二个元素也出现在相同的onclick事件上。 I can't figure out how to code that. 我不知道如何编码。 I tried something like this, but it didn't work 我尝试了类似的方法,但是没有用

$(document).ready(function(){
    //hide the all of the element with class abstract
    $("..meetings-list .meeting_title_and_description .abstract").$("..meetings-list .meeting_title_and_description .secondthingtohide").hide();
    //toggle the componenet with class meetingname
    $("..meetings-list .meeting_title_and_description .meeting_name").click(function(){
    $(this).next(".meetings-list .meeting_title_and_description        .    abstract").$("..meetings-list .meeting_title_and_description .abstract").$("..meetings-list .meeting_title_and_description .secondthingtohide").slideToggle(50);
     });
});

Anybody an idea? 有人有主意吗?

Try using wildcard selector approach for this one, such as this: 尝试为此使用通配符选择器方法,例如:

$("[.^=meeting]").toggle();
 // OR //
$("[class^=meeting]").hide();

[class^=meeting] or [.^=meeting] tells jQuery to select all tags with the class starting with 'meeting', and toggle them all with whichever function you want (ie show(), hide(), fadeIn(), fadeOut(), and such). [class ^ = meeting]或[。^ = meeting]告诉jQuery选择以'meeting' 开头的类的所有标签,并使用所需的任何功能(即show(),hide(),fadeIn())切换它们,fadeOut()等)。

$("[.$=meeting]").show();
 // OR //
$("[class$=meeting]").fadeOut();

[class$=meeting] or [.$=meeting] tells jquery to select all tags with the class ending with 'meeting', and toggle them all with whichever function you want (ie show(), hide(), fadeIn(), fadeOut(), and such). [class $ = meeting]或[。$ = meeting]告诉jquery选择以'meeting' 结尾的类的所有标签,并使用所需的任何功能(即show(),hide(),fadeIn())切换它们,fadeOut()等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM