Saturday October 11 2008

jquery show/hide

I’m trying to do something with jquery but it just isn’t working. I’ve got a list of entry titles that want to be hidden until the user clicks on the h2 tag above it.

Here is the code - I’ve also posted this on the EE forums.

<h2 class="toggle">All Teachers</h2>
    <
div class="view">
    
{exp:weblog:entries weblog="teachers" orderby="date" sort="desc" limit="100" status="open" dynamic="off" disable="member_data|pagination|trackbacks"}
    {categories}
<h3><a href="{permalink=">{title}</a></h3>{/categories}
    {
/exp:weblog:entries}
    
</div>

<
scr*pt type="text/javascript">
    $(
document).ready(function(){
        
$('div.view').hide();
        $(
'h2.toggle').click(function(){
            
$('div.view').show();
            $(
this).hide();
        
});
    
});
</
scr*pt


*edit* fixed a typo in the code, but it’s still not working.


Sean. inscribed these words of wisdom on Saturday Oct 11, 2008 at 02:06 PM | tags: ee thread, code, jquery |
Picture of Peter

Peter wrote 13 words  on  Saturday Oct 18, 2008  at  06:21 PM Switzerland

Hi Sean

This should work as supposed:


$(document).ready(function(){
  $(‘div.view’).hide();
  $(‘h2.toggle’).click(function(){
      $(this).next().toggle();
  });
});

Sean.

Sean. wrote 17 words  on  Sunday Oct 19, 2008  at  08:07 AM Korea (South)

Peter,
Thanks, I appreciate your comment here and on the EE forum. I did get it working.

Commenting is not available in this weblog entry.
logo subscribe to rss
theme forest

About Me

This blog is my journey to professional web design and development. Here I will write about code and things I learn about xhtml, css, javascript, jquery, Expression Engine, Wordpress and any other CMS I need to use in my new career.

I will be adding links to the sidebar as I find useful resources and blogs. I'm also looking forward to getting feedback from other designers and developers. Thanks for dropping by.

Web Design Blogs

Tutorials

Online Resources

Find Work

Stock Imagery

Validators

CMSs

Recently Bookmarked

Tag Cloud

Reading List

Categories

subscribe to rss