tags:

views:

109

answers:

3

I am trying to load HTML in to an area on my page and I can load pure text all okay, see example below:

function(msg) {
    // Replace the div's content with the page method's return.
    $("#CategoryExtension").text(msg);
}

However when I try to include HTML content it displays it as is, and places a quote around the content.

How can I get over this?

+5  A: 

HTML ? Try

$("#CategoryExtension").html(msg);
meder
+1  A: 

remember that, there is text() and html()

text() is the same as the Text property and html() is the innerHTML property, when playing with div's you should change the innerHTML property just like

document.getElementById('myDiv').innerHTML = 'This is <strong>my bold text</strong>.';

in the jQuery world you accomplish the same as

$("#myDiv").html('This is <strong>my bold text</strong>.');

it helps understand a little bit about HTML and Javascript :)

balexandre
+1  A: 

You need to use html( ). For example:

$("#CategoryExtension").html("<span>Hello</span>");

Also, please check out jQuery Documentation to familiarize yourself with the API. It will help you a lot.

Randell