0

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?

1 Answer 1

2

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();
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.