Grow your CSS skills. Land your dream job.

Jquery selecting all selectors but not $(this)

  • # January 20, 2009 at 7:12 pm

    Hi,
    what I’m trying here is to select all other "dt" selectors but this one i just clicked.
    My intention is to close all other "dt" tags if another is clicked.
    Opening just works good, but don’t know how i should program jquery that it should close all other "dt" tags.

    thanks a lot for help
    here is the code so far.
    i let getclassname() get the name of the class which every <dt> and <dd> which belong to each other, have in common.

    Code:
    $(document).ready(function(){
    $(“dt”).toggle(
    function(){
    $(getclassname($(this))).slideDown(“slow”);
    },
    function(){
    $(getclassname($(this))).slideUp(“slow”);
    });

    function getclassname (pointer){
    var name = pointer.attr(‘class’);
    var class = “dd.” + name;
    return class;
    }
    });

    Rob
    # January 20, 2009 at 7:55 pm

    now someone much more clever than I am will come back to you saying something along the lines of "create a CSS class called something like on, then attach it to the this" then you can use an if statement to do whatever you want to thing thing that is on…

    omg that was just rambling… I need to sit down and learn this stuff!

    I know what I mean but I have no idea how to tell you :D

    something like here:

    viewtopic.php?f=5&t=1465

    As long as the jQuery can know which is "on" it can do something with it…

    Im shutting up now :)

    # January 21, 2009 at 4:53 am

    ok i found something to get it work.

    Code:
    $(“dt”).click(
    function(){
    $(this).next(“dd”).slideToggle().siblings(“dd”).slideUp();
    });

    but another question, it flashes/flickers/jump on a click and before it slides down. do you have the same error?
    thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".