0

Why this doesn't work? It's supposed to load content of another html file into DIV with bottom id

<!DOCTYPE html>
<html lang="en">
  <head>
    <script type="text/javascript">
function loadContent(href, container){
  $wrapper = $('<div>'); 
  $wrapper.addClass('loaded_content_wrapper').appendTo(container).load(href, function(){
    $(this).animate({marginLeft:0}, 'slow').prevAll().animate({marginLeft:'-100%'}, 'slow', function(){
      $(this).remove();
    });
  })
}
    </script>
  <link href="style.css" rel="stylesheet" type="text/css">
  </head>

<div onClick="loadContent('hello-world.html', $('#bottom'))">Home</div>
<div id="bottom">
ramkaramka
</div>

</html>
2
  • 2
    Just so you know, you're missing the <body> tags Commented Nov 29, 2013 at 15:53
  • @DavidThomas I don't see anything there which would run before DOM ready. All DOM querying code is contained within function bodies... Commented Nov 29, 2013 at 16:02

1 Answer 1

1

It worked if add script tag for jquery.js and set jquery.js , hello-world.html

<!DOCTYPE html>
<html lang="en">
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
function loadContent(href, container){
    $wrapper = $('<div>'); 
    $wrapper.addClass('loaded_content_wrapper').appendTo(container).load(href, function(){
        $(this).animate({marginLeft:0}, 'slow').prevAll().animate({marginLeft:'-100%'}, 'slow', function(){
            $(this).remove();
        });
    })
}
        </script>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

<div onClick="loadContent('hello-world.html', $('#bottom'))">Home</div>
<div id="bottom">
ramkaramka
</div>

</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.