Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which event belongs to "type text into textfield" using jQuery

Just imagine a formular where there is a checkbox and a textfield. If someone starts typing into the textfield "bla bla bla whatever", the checkbox should tick itself. Is there a event that corresponds to the typing or do I have to use .focus ?

like image 340
Andre Avatar asked Jun 09 '10 07:06

Andre


1 Answers

events which are fired on typing are:

  • onkeydown (jQuery: keydown)
  • onkeyup (jQuery: keyup)
  • onkeypress (jQuery: keypress)

You may create an event handler to any of those to modify or influence users input. Also be aware of .preventDefault() and .stopPropagation() functions, which prevent the default behavior for an element or suppress the event bubbling up the DOM.

References: keyup, keydown, keypress, preventDefault(), stopPropagation()

like image 160
jAndy Avatar answered Sep 18 '22 07:09

jAndy