treehouse : what would you like to learn today?
Web Design Web Development iOS Development

jquery help

  • I am writing some jquery to load content and I am trying to use vars. I tried it like this

    var $about = $('#loadContent').load('about.html');

    the problem is that the div that I want to load the about.html page into shows the content even though that is a variable above. I would think in order to show the content, I would have to do $about.show();

    Got any clue?
  • The way jQuery works is that when you apply a method to a jQuery object, as in your var statement, it returns a jQuery object. Basically, when you declare the var $about, you are running the load() method on the #loadContent jQuery object. If you want the load method to run later on, apply that method later on when you're ready for it.