I'm trying to use a jquery data selector to add/remove a class to an element.
$("#side_categories .testbox").click(function () {
var category = $(this).data('category'); //get the category from the clicked button
if ($('#side_categories .testbox').hasClass('activated')) {
//otherInput is the hidden text input
$('#listings .deals:data("category"="+category+")').removeClass('activated');
} else {
$('#listings .deals:data("category"="+category+")').addClass('activated');
}
});
In my test box I have data-category set on each trigger to pass it over. The category going into data-category is filled in via php.
Can't seem to get this to work, have been seeing errors like:
regular expression too complex
[Break On This Error] while (m = matcher.exec(expr)) {
or when I'm using the older function written by james padolsey, i get the following:
uncaught exception: Syntax error, unrecognized expression: data
I just want to be able to add/remove classes from LI's based on checkbox selections.
Many thanks in advance!