Reputation: 13
I am trying to append this list item <li><i class="fa fa-star" ></i></li>
to an unordered list using JQuery$("ul.star-rating").append("<li><i class="fa fa-star" ></i></li>")
however I get an error that there a missing ")".
I assume that I should escape the white-space between the classes "fa"&"fa-star".I don't know if my assumption is correct and I wanted to know how can I achieve such a result:
<ul class="star-rating">
<li><i class="fa fa-star"></i></li>
</ul>
Upvotes: 0
Views: 501
Reputation: 131
This should work for you.
You have to use single quotes when you start with double quotes or otherwise
$("ul.star-rating").append("<li><i class='fa fa-star'></i></li>")
Upvotes: 0
Reputation: 1190
Use
$("ul.star-rating").append("<li><i class='fa fa-star'></i></li>");
You are using double quotes inside a string that terminates the argument literal of append method.
Upvotes: 0
Reputation: 4776
The problem is your use of quotes in this part:
"<li><i class="fa fa-star" ></i></li>"
You need to escape the "fa fa-star"
quotes. Otherwise it's like jamming several different objects together "<li><i class="
, literal fa fa-star
and " ></i></li>"
. Or you could just single quotes on the outside.
Upvotes: 1