Param Veer
Param Veer

Reputation: 786

click to add class in jquery

i made a light box and i am having a problem in a step where on click i start a function but i also want to add a class but when i use this code i wrote i am not able to add class on click and it adds its automatically when the light box loads up . here is the line of the whole code i am trying to work out

play: this.list.find(".btnPlay").click(g.play).addClass("btnPlayOn"),

using this i am able to call the function g.play but how to use addclass on click i am not able to achieve this any help on this?

Upvotes: 0

Views: 65

Answers (1)

Pratik Bhatt
Pratik Bhatt

Reputation: 911

You need to add class in g.play function.. as you are using chaining... addClass will be executed immediately after click... It will not wait till your play function complete its action... so try to add addClass in play function.... hope it will work

Upvotes: 1

Related Questions