user2034164
user2034164

Reputation: 303

quotation marks in Jquery creates error

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

Answers (3)

sdagli
sdagli

Reputation: 121

You can access with

$('li[class=last-item SunItem-8]').somefunction();

Upvotes: 0

PKeidel
PKeidel

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

Innovation
Innovation

Reputation: 1534

$('<li class="   last-item SunItem-8">').before("</ul><ul>");

Upvotes: 1

Related Questions