开发者

add html to div with jQuery

I am trying to add some addition开发者_StackOverflowal html to a div with id slideshow using jQuery. My code:

$("#slideshow").append("<a id="prev" title="Previous Slide">Previous Slide</a><a id="next" title="Next Slide">Next Slide</a>");

This isn't working, can anyone tell me what I am doing wrong?


You're mixing quotes.

Your string goes from the first " to the second ", meaning that the string only contains "<a id=". The string is followed by the identifier prev, then another string, creating a syntax error.

Change the outer quotes around the string to ', like this:

'<a id="prev" title="Previous Slide">Previous Slide</a><a id="next" title="Next Slide">Next Slide</a>'


your not escaping your quotes best way to fix is to put the append in single quotes

$("#slideshow").append('<a id="prev" title="Previous Slide">Previous Slide</a><a id="next" title="Next Slide">Next Slide</a>');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜