Posted By

chendrix on 11/07/10


show file hide external

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Use anchor tag to show/hide information loaded from an external file

 / Published in: jQuery

When the anchor tag is clicked, load the ul#movies from new_file.html, and append to the div#container inside a div#info, changing the DOM, but only the first time clicked. Each subsequent time, toggle the show/hide status.

Modified version of code from Jeffrey Way's jQuery for Absolute Beginners: Day 10 on ThemeForest.

  1. $('a').one('click', function() {
  2. $('<div id="info" />').load('new_file.html ul#movies', function() {
  3. $(this).hide().appendTo('div#container').slideDown(1000);
  4. });
  6. });
  7. $('a').click(function() {
  8. $('div#info').toggle(1000);
  9. });

Report this snippet  

You need to login to post a comment.