I know how to load external text from a .txt file using
<div id="text"> <div>
and javascript
$("#text").load("pathtofile/content.txt"); // element's id should be in string form
but can this be done between two < p > tags instead of inserting into a div? if so how?
Thanks
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With