tlob wrote:
Hy there.
I'm pretty new to jQuery and JS in general. I managed to build
something. I learned a lot! THX jQuery guys. When you look into my
code, could it be shorter, smarter, sharper? especially this part:
[code]
$(document).ready(function(){
                        $("#linkDetail1").click(function(){
                           $("#detail1").slideToggle("slow");
                           return false;
                         });

                        $("#linkDetail2").click(function(){
                                $("#detail2").slideToggle("slow");
                                return false;
                        });

                        $("#linkDetail3").click(function(){
                                $("#detail3").slideToggle("slow");
                                return false;
                        });
}

This might do what you want, replacing all those:

            $("div.details").each(function() {
                var elt = $(this);
                $("#linkD" + this.id.substring(1)).click(function() {
                    elt.slideToggle("slow");
                    return false;
                });
            });
It would be simpler still except for the need to work around a name mismatch in detail2 versus linkDetail2. If you changed your markup slightly, you could use the simpler

                $("#link-" + this.id).click(function() {

Cheers,

  -- Scott

Reply via email to