Finding The Closest Span With A Specific Class Inside A Div February 17, 2024 Post a Comment I want to find the closest span with class error_span. How can I do that using jQuery? input. To solve your issue traverse to a common parent of both the input and span and use find() from there. Try this:$("#reimburse_price").blur(function() { checkNumInput('#' + this.id); }); functioncheckNumInput(id) { var $input = $(id); if ($input.val() == "") { $input.get(0).setCustomValidity('Please fill out this field'); $input.closest('.form-group').find('.error_span').text("Please fill out this field").toggleClass("hidden text-danger"); } } Copy Share You may like these postsDo I Still Need To Use The Title Attribute If My Element Has A ``?How To Enlarge Multiple Pictures Using JavascriptWhy Css Variables Override Another File's Css Variable?How Can I Control The Placement Of My Chart.js Pie Chart's Legend, As Well As Its Appearance? Post a Comment for "Finding The Closest Span With A Specific Class Inside A Div"
Post a Comment for "Finding The Closest Span With A Specific Class Inside A Div"