jquery - If body class is the same as another class, add a new class -
i'm trying match body class (auto generated wordpress) li class (also auto generated). if match need add new class li.
e.g
if body
class="postid-621"
, li
on page class="postid-621"
need enter new class li
called current-product
.
bear in mind id auto generated can't hard code in.
is possible?
you have 1 serious problem, in wordpress body has lot of classes, standard theme has :
<body class="single single-post postid-621 single-format-standard masthead-fixed singular">
so have postid
class, , compare numbers, that's want.
$('#test').attr('class').split(/\s+/).filter(function(k) { if ( $.trim(k).indexof('postid') === 0 ) { $('li.' + $.trim(k)).addclass('new_class_to_add'); } });
just getting class attribute , comparing fail in wordpress
Comments
Post a Comment