loading external text from .txt to a html file

后端 未结 1 1442
后悔当初
后悔当初 2021-01-06 09:14

I know how to load external text from a .txt file using

and javascript

 $(\"#text\").l         


        
相关标签:
1条回答
  • 2021-01-06 10:15

    To get the text from only a paragraph from the file, try this:
    HTML:

    <div id="tempDiv" style="display: none;"></div>
    <p id="text"></p>
    

    JQuery:

     var tempDiv = $('#tempDiv');
     tempDiv.load("pathToFile/content.txt");
     var html = tempDiv.find('#theParagraphId').html();
     $('#text').html(html);
    
    0 讨论(0)
提交回复
热议问题