Reputation: 5086
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?
Upvotes: 25
Views: 78100
Reputation: 17640
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>');
Upvotes: 3
Reputation: 887413
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>'
Upvotes: 30