Reputation: 303
I am trying to execute this:
$("<li class=" last-item SunItem-8").before("</ul><ul>");
but because of that " I am getting an error how can I capture this but not error out?
Upvotes: 0
Views: 44
Reputation: 121
You can access with
$('li[class=last-item SunItem-8]').somefunction();
Upvotes: 0
Reputation: 2589
Your selector isn't a valid jQuery selector.
$('<li class="last-item SunItem-8"/>').before("</ul><ul>"); // note the added '/>' at the end of the selector
This way you create a new li-Element. If you don't want to create a new one but want to select an existing one, you should use:
$('li[class="last-item SunItem-8"]')
Upvotes: 0