简体   繁体   中英

add html to div with jQuery

I am trying to add some additional 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>'

你没有逃脱你的报价最好的解决方法是将附加单引号

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM