jQuery change content of div code example

Example 1: jquery change text of div

$('#dialog_title_span').text("new dialog title");

Example 2: jquery replace html

$(element).html("Hello World");

Example 3: jqueryreplace content of div

$('#content-container').html(linkText);

Example 4: change inside div with jquery

$('.click').click(function() {
    // get the contents of the link that was clicked
    var linkText = $(this).text();

    // replace the contents of the div with the link text
    $('#content-container').html(linkText);

    // cancel the default action of the link by returning false
    return false;
});

Tags:

Html Example