javascript - jquery attribute select on click not working -
i have problem 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 click button class .adm_vid_stcs_refresh_btn
the following error:
uncaught error: syntax error, unrecognised expression: ['data-ctg-id']
how can select class attribute jquery?
when using attribute selector has attribute selector have used, attribute name should not not enclosed 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(); });