views:

16

answers:

1

I already have the "scroll to" and toggle functions in place:

$("a.view").click(function(){
    $("#content").slideToggle("slow");
    return false;
});

And the scrolling is taken care of via this handy little plugin.

Now how do I load some html from another page into this newly opened div called #content. I've tried a few things here and there but just can't seem to get it to work.

Any ideas please?

+1  A: 

Pretty trivial using jQuery.

$('#content').load('path/file.html', function() {
   // done
});

You may also "partial" load data, for instance

$('#content').load('path/file.html #container', function() {
   // done
});

will only load the element with the id `#container' out of file.html.

Ref.: .load()

jAndy
But I would like the content to load after I click the button. Would this still work in this instance?
lorenzium
@lorenzium: sure, you would just pull the `load()` method into your `click event handler`. Notice that `#content'` can be replaced with `$(this)` in this specific case.
jAndy
Thanks jAndy - you're a champ! Got it to work after that last explanation. Cheers.
lorenzium