I've written this script to find <fieldset> tags with a child containing gfield_error, and add a class wow-error into that <fieldset>.
The problem is it works too well and if it finds gfield_error anywhere on the page it adds the class to every <fieldset> on the page, not just those with a child that has gfield_error.
jQuery(document).ready(function( $ ) { $(':has(.gfield_error) > fieldset').addClass('wow-error'); }); <fieldset class="gfieldset"> <legend class="gfieldset-legend ">Name</legend> <ul class="gform_fields"> <li id="field_2_95" class="gfield gfield_error"> <p>Some content</p> </li> </ul> </fieldset> I'm sure it's an elementary mistake, could anyone offer guidance.
https://stackoverflow.com/questions/65963534/limiting-the-scope-of-jquery-script-to-immediate-ancestors January 30, 2021 at 08:43AM
没有评论:
发表评论