Hi! Heres a couple things i might do

      $('a.show').hide();
      $('a.hide').click(function(){
              $('a.show').show();
              $('h2.title,.view-header-latest').add(this).hide(); //
Combine multiple
              $.cookie('hideShow","hide",{expires:365}); // Only need one
cookie.
              return false;
      });

      var hideShow = $.cookie('hideShow');
      if (hideShow=="hide") {
              $('a.hide,h2.title,.view-header-latest').hide(); // Combine
multiple
              $('a.show').show();
      };

      $('a.show').click(function(){
              $(this).hide();
              $('a.hide,h2.title,.view-header-latest').show();
              $.cookie("hideShow","show");
              return false;
      });
      if (hideShow=="show") {
              $('h2.title,.view-header-latest').show();
      };


On 6/11/07, bsuttis <[EMAIL PROTECTED]> wrote:


Hi all,

After searching for a solution to my subject and not finding it, I've
put together my own, which while working, feels rather long to me, and
as more of a designer/themer, I'm wondering if this is the optimal
code from a developer's point of view. I'm using the excellent jQuery
cookie plugin for the cookies.

Here's my jQuery code:

<code>
        $('a.show').hide();

        $('a.hide').click(function(){
                $(this).hide();
                $('a.show').show();
                $('h2.title').hide();
                $('.view-header-latest').hide();
                $.cookie('hide', '.view-header-latest', {expires:365});
                $.cookie('show', null);
                return false;
        });

        var hide = $.cookie('hide');
        if (hide) {
                $('a.hide').hide();
                $('a.show').show();
                $('h2.title').hide();
                $('.view-header-latest').hide();
        };

        $('a.show').click(function(){
                $(this).hide();
                $('a.hide').show();
                $('h2.title').show();
                $('.view-header-latest').show();
                $.cookie('show', '.view-header-latest', {expires:365});
                $.cookie('hide', null);
                return false;
        });

        var show = $.cookie('show');
        if (show) {
                $('h2.title').show();
                $('.view-header-latest').show();
        };
</code>

What this does is uses a ul of 2 links, a show and a hide, to control
a div below it -- hiding the div as well as the opposite link while
doing so (ie. when you click the Hide li a, it hides too and presents
the Show li a). Any suggestions are appreciated, justr started getting
my hands dirty with jQuery this weekend. Thanks!


Reply via email to