0

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?

3 Answers 3

5

HTML ? Try

$("#CategoryExtension").html(msg);
Sign up to request clarification or add additional context in comments.

Comments

1

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 :)

Comments

1

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.

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.