jQuery .keyPress() - How to get value of input which triggered event?
问题 Trying to do some jQuery validation (without the plugin - please no answers like "Just use the validate-js plugin"). I'm wiring up a client-side event handler keypress for each "required field" on doc ready: $(document).ready(function() { $('#myform input.required').each(function() { $(this).keypress(onRequiredFieldKeyPress); }); }); Which correctly fires this event on each keypress: function onRequiredFieldKeyPress() { if ($(this).val().trim() == '') { $(this).next('em').html('*').show(); //