0

I cannot seem to append HTML into a div tag. For instance, if I do this:

$(".someDiv").dblclick(function(){
         alert("here");
         $(this).html("<b>hello!</b>");

    });

OR

$(".someDiv").dblclick(function(){
         alert("here");
         $(this).append("<b>hello!</b>");

    });

However, if I exclude any HTML tags, the function works just fine. I have searched around online and no one seems to be having this problem... I am using Chrome. Any help is greatly appreciated!

2 Answers 2

1

You've just put your closing quote mark in the wrong place.

$(this).append("<b>hello!</b>");
Sign up to request clarification or add additional context in comments.

5 Comments

Lol, weird it got shifted while I modified a few things. However, it is correct on my working copy
@user1260028 very strange then, there's nothing else wrong in the snippet you posted.
Could it be chrome trying to prevent HTML injection?
It also does not seem to work in Internet Explorer... My code is one to one with the above other than some name changes. The alert fires properly just to make sure its running through that code. Chrome reports no javascript errors.
@user1260028 no, this is completely standard jQuery. What sort of element is this ?
0

Didn't realize I put it into an XHTML file. The above code will not work in an XHTML file.

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.