Skip to content Skip to sidebar Skip to footer

Loading External Text From .txt To A Html File

I know how to load external text from a .txt file using
and javascript $('#text').load('pathtofile/content.txt'); // element's id should be in

Solution 1:

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);

Post a Comment for "Loading External Text From .txt To A Html File"