Reputation: 592
I have a problem with the following:
$(document).on("click", ".adm_vid_stcs_refresh_btn['data-ctg-id']", function(){
Categories.ctgId = $(this).attr("data-ctg-id");
Categories.ctgType = $(this).attr("data-ctg-type");
Categories.Ajax();
});
When a click the button with class .adm_vid_stcs_refresh_btn
I get the the following error:
Uncaught Error: Syntax error, unrecognised expression: ['data-ctg-id']
How can I select a class with attribute I jquery?
Upvotes: 0
Views: 58
Reputation: 388316
When you are using an attribute selector like the has attribute selector you have used, the attribute name should not not be enclosed like a string literal in ''
or ""
".adm_vid_stcs_refresh_btn[data-ctg-id]"
So
$(document).on("click", ".adm_vid_stcs_refresh_btn[data-ctg-id]", function () {
Categories.ctgId = $(this).attr("data-ctg-id");
Categories.ctgType = $(this).attr("data-ctg-type");
Categories.Ajax();
});
Upvotes: 2