How to add content from file using jQuery?
I have main html document:
<html><head></head>
<body>
    <div id="content">
    </div>
</body>
</html>
Also I have a content file (not the html document, just html code):
<div class="CodeRay">
<div class="code"><pre><span class="no">   1</span> require
....
</pre></div>
I want to add the content file to html document like here:
<html><head></head>
    <body>
        <div id="content">
            <div class="CodeRay">
            <div class="code"><pre><span class="no">   1</span> require
            ....
            </pre></div>
     开发者_高级运维   </div>
    </body>
</html>
How to use jQuery to accomplish this task? Also I need to run this site localy. Thanks.
EDIT: Locally means like this "file:///E:/Work/ReadTheCode/main.html"
Use jQuery's .load() function. The code would probably look something like this:  
$(document).ready(function(){
  $('#content').load('contentFile.html');
});
If you need more info, here is the link to jquery's load documentation.
you can use something like this:
$('#result').load('ajax/test.html');
See: http://api.jquery.com/load/
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论