Hercell Yutiko
Hercell Yutiko

Reputation: 35

JQuery How can I add a class to this?

I need to add a class to this span in this line of code:

$(":text").after("<span>*</span>")

How do I add a class to this?

I have tried

$(":text").after("<span>*</span>").addClass("error");

and

$(":text").after('<span class="error">*</span>');

Upvotes: 0

Views: 28

Answers (1)

wmk
wmk

Reputation: 4626

The <span> should have a class?

How about

$(":text").after('<span class="myclass">*</span>');

note the switch to single quotes...

Upvotes: 1

Related Questions