3

I'm having a problem with jQuery append just in Internet Explorer 8 (I didn't check earlier versions). On launch (in a ready() function) I append a div to my container div. This doesn't work in IE8 though, no div is added. I checked this by returning the length of $('div#options') in the console. Why isn't this working?

This is my code to append the div:

$('div#container').append('<div id="options"><a href="#" id="delete"><a href="#content" id="edit"></div>');

I also tried to use prepend() and appendTo(), but they didn't work either... Can anyone help me?

Thanks!

3 Answers 3

10

Perhaps your broken links are causing the issue

$('div#container').append('<div id="options"><a href="#" id="delete">Delete</a><a href="#content" id="edit">Edit</a></div>');
Sign up to request clarification or add additional context in comments.

3 Comments

This indeed was the problem. I decided to mark mcgrailm's answer though, since he was a bit earlier. Nonetheless thanks for the help!
Please recheck the times :) Either way, still glad I could help.
So almost 7 years later this should be changed, smh @Frog
4

try it like this

 $('#container').append('<div id="options"><a href="#" id="delete">delete</a><a href="#content" id="edit">edit</a></div>');

working demo tested in ie8

1 Comment

Thanks! I must have looked at the code too much, can't believe I missed something that easy.
1

In IE it is possible that DOM is not updated after the append. Use another method to ensure if the tag is appended or not. (For example use Developer Tools)

1 Comment

That's right... I always forget this. In IE 7 at least F12 (Developer Tools) there's a refresh button in the HTML that allows you to refresh the HTML after jQuery append do its thingy. :)

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.