Tuesday, March 2, 2010

How to replace innerHTML of a div using jQuery?

Most of you guys are familiar with innerHTML of Javascript. However this sorta stuff is quite old. Lets try with Jquery . Its quite simple, Lets see with a small example

Suppose we have a javascript like document.getElementById('mydivTag').innerHTML = 'Hello World';

To convert to Jquery its
$('#mydivTag').html('Hello World');

Thats it.. Its done..

When you deal with Value or text you can use
$('#mydivTag').text('Hello world')

No comments:

Post a Comment