Dora
Dora

Reputation: 6970

why wouldn't this selector work? JS

I have a class name active and in js I have something like this

var selectClass = active;
var a = $("'." + selectCLass + "'");
a.on('click', function(){})

When I do this, it would keep on giving me errors.

What am I missing here?

Upvotes: 0

Views: 24

Answers (1)

tanaydin
tanaydin

Reputation: 5316

Generated selector string has errors... make it like

var a = $("." + selectCLass);

Upvotes: 3

Related Questions