Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to replace innerHTML of a div using jQuery?

How could I achieve the following:

document.all.regTitle.innerHTML = 'Hello World';


Using jQuery where regTitle is my div id?
by

2 Answers

aashaykumar

$("#regTitle").html("Hello World");
RoliMishra
The html() function can take strings of HTML, and will effectively modify the .innerHTML property.

$('#regTitle').html('Hello World');


However, the text() function will change the (text) value of the specified element but keep the HTML structure.

$('#regTitle').text('Hello world');

Login / Signup to Answer the Question.