In jQuery my :contains selector is ignored -
In jQuery my :contains selector is ignored -
i'm trying add together class element provided word 'yes' appears somewhere in descendants. far i've written below code applies class regardless of whether word appears or not. ideas?
$(document).ready(function() { if ($(".views-row-1 .field-item:contains('yes')")) { $(".views-row-1 .field-name-field-exp").addclass("solexpandable"); } });
this:
$(".views-row-1 .field-item:contains('yes')")
is true in boolean context regardless of (if anything) matched. if want see if selector matched anything, check length
:
if ($(".views-row-1 .field-item:contains('yes')").length) { $(".views-row-1 .field-name-field-exp").addclass("solexpandable"); }
jquery contains
Comments
Post a Comment