html - jquery `$form.find` get element inside form -
i have jquery code:
if ($form.find('.required').filter(function(){ return this.value === '' }).length > 0) { } within if statement, how can each element , add class it?
i tried $(this).addclass("emptyselect"); adds class form , not element
perform addclass right after filter() call
var emptyelements = $form.find('.required').filter(function() { return this.value === '' }); if (emptyelements.length > 0) { emptyelements.addclass("emptyselect"); } however, can connect filter statement addclass without if since filter return empty elements
$form.find('.required').filter(function() { return this.value === '' }).addclass("emptyselect");
Comments
Post a Comment