To make a button you should probably use the button
tag. You can also use an input
tag if you really want, but button
is a bit easier.
You know when someone clicks a button by listening for the click
event.
Open example in new window
Open example in new window
Text input
You have two choices with text input - one for shorter input and one for longer input. You’ll use the shorter one 99.999% of the time.
To get the contents of a text input, you select your element and then use .property('value')
.
Open example in new window
Open example in new window
You can also listen for each time a user presses a key in the input field, just in case you want to do the quick-reactive searching like Google does.
Open example in new window
Open example in new window