> Sure, there are a number of ways you could do that. But it's hard to suggest
> what might be best without seeing the HTML code - can you post an example?
> Also, it sounds like you do have control over the HTML code so you can
> change it as needed, subject to your layout design requirements, is that
> right?
>
> -Mike

To answer your last question first: yes, I do have control over the
HTML code and all the Javascript and jQuery code, so I can change it
as needed.

For additional information, I have pretty much figured out how to
perform the function I want using a combination of straight up
Javascript and also some jQuery.  If seeing the website would help
you, it is here: www.freewebs.com/edauenhauer. (The function I was
aiming for was to be able to click on a "title" on the left and have
it open up a "content" div on the right.  Whenever a new "title" would
be clicked, the already visible "content" div would close and the new
one would open.)

For further clarification, I'm basically trying to emulate the Harry
Maugans style collapsible div (http://www.harrymaugans.com/2007/03/05/
how-to-create-a-collapsible-div-with-javascript-and-css/)  with
jQuery.  Here is my Javascript function:

    function toggleDiv(divid){
        document.getElementById(divid).style.display = 'block';
    }

The jQuery code that I'm using in conjunction with that is this:

   $(document).ready(function() {
     $('div.content').hide();
     $('a.title').mousedown(function() {
        $('.content:visible').hide(300);
     });
   });

And then a snippet of the HTML is this:

     <div class="title_container">
     <a href="javascript:;" onclick="toggleDiv('div1');"
class="title">Title 1</a>
     <a href="javascript:;" onclick="toggleDiv('div2');"
class="title">Title 2</a>
     </div>

     <div class="content" id="div1" style="display:none;">blah blah
blah</div>
     <div class="content" id="div2" style="display:none;">blah blah
blah</div>

In summary, the "Titles" are held in a separate div which gives access
to all the titles independent of other content.  When the titles are
clicked on, they use the "toggleDiv" Javascript function to open up a
"Content" div.  When this happens, jQuery is used to close all other
visible "Content" divs so that only the most recent one clicked is
showing.

Is really isn't a big deal so don't spend too much time on it, but I
was wondering if there was a way to completely cut out the "toggleDiv"
Javascript function and do it all through jQuery.  The advantages for
me would be primarily animation, which is always cool.  Again, thanks
for any help you can offer.

Reply via email to