javascript - Can't use this to point a selected element with jQuery -
why js not apply class element please ?
<input type="password" name="customer-new-password" class="form-control"> <script> if($("input[name='customer-new-password']").val()=='') { $(this).addclass('required'); } else { $(this).removeclass('required'); } </script>
thanks.
why think $(this) point selected object?
try instead:
var $input = $("input[name='customer-new-password']"); if($input.val()=='') { $input.addclass('required'); } else { $input.removeclass('required'); }
Comments
Post a Comment