0

I have a text file that is modified by different python scripts, and I want to create a jquery function that detects each change in that file and to display that change in an initially empty html div

<div id="logtext"> </div>

using

document.getElementById('logtext').innerHTML= new_content_of_the_file;

( something similar to displaying a logfile ) how can I do that?

3 Answers 3

2

You can also use HTML like this:

var content = data_from_python;
$("#logtext").html(content);

The difference between HTML and append() function is that HTML replaces the content of your div. It's the equivalent of innerHTML while append just adds content to the end of an element.

Here is a reference on this topic:
.append()
.html()

Sign up to request clarification or add additional context in comments.

Comments

0

Is this what you are looking for?

$('#logtext').append('<p>' + resultMessage + '</p>');

1 Comment

Since it looks like he is appending JSON data, I would use <pre> tags for better formatting.
0

you can use append or html like this:

$("#logtext").append("to do");

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.