View on GitHub

reading-notes

Forms and JS Events

Form Controls

There are several types of form controls that you can use to collect information from visitors to your site.

Adding Text:

Making Choices:

Submitting Forms:

Form Structure

Text Input

Submit Button

Different browsers will show submit buttons in different ways and tend to fit the visual presentation of the browser. If you want to control the appearance of a submit button, you can either use CSS, or you can use an image for the button.

Grouping Form Elements

Most browsers will show the fieldset with a line around the edge to show how they are related. The appearance of these lines can be adjusted using CSS.

Lists, Tables and Forms

Bullet Point Styles

The list-style-type property allows you to control the shape or style of a bullet point (also known as a marker).

Unordered Lists

For an unordered list you can use the following values: none, disc, circle, square.

Ordered Lists

For an ordered (numbered) list you can use the following values: decimal, decimal-leading-zero, lower-alpha, upper-alpha, lower-roman, upper-roman.

Positioning the Marker

Lists are indented into the page by default and the list-style position property indicates whether the marker should appear on the inside or the outside of the box containing the main points. This property can take one of two values:

outside

The marker sits to the left of the block of text. (This is the default behavior if this property is not used.)

inside

The marker sits inside the box of text (which is indented). In the example shown, the width of the list has been limited to 150 pixels. This ensures that the text wraps onto a new line so you can see how the value of inside sits the bullet inside the first line of text.

Events

When you browse the web, your browser registers different types of events. It’s the browser’s way of saying, “Hey, this just happened.” Your script can then respond to these events. Scripts often respond to these events by updating the content of the web page (via the Document Object Model) which makes the page feel more interactive. In this chapter, you will learn how:

Different Event Types

Here is a selection of the events that occur in the browser while you are browsing the web. Any of these events can be used to trigger a function in your JavaScript code.

UI Events:

Occur when a user interacts with the browser’s user interface (UI) rather than the web page.

Event Description
load Web page has finished loading
unload Web page is unloading (usually because a new page was requested)
error Browser encounters a JavaScript error or an asset doesn’t exist
resize Browser window has been resized
scroll User has scrolled up or down the page

Keyboard Events:

Occur when a user interacts with the keyboard (see also input event).

Event Description
keydown User first presses a key (repeats while key is depressed)  
keyup User releases a key  
keypress Character is being inserted (repeats while key is depressed)  

Mouse Events:

Occur when a user interacts with a mouse. trackpad, or touchscreen.

Event Description
click User presses and releases a button over the same element
dblclick User presses and releases a button twice over the same element
mouseddown User presses a mouse button while over an element
mouseup User releases a mouse button while over an element
mousemove User moves the mouse (not on a touchscreen)
mouseover User moves the mouse over an element (not on a touchscreen)
mouseout User moves the mouse off an element (not on a touchscreen)





201 Go back Home
read## Name and Link
read01 Introductory HTML and JavaScript
read02 HTML Text, CSS Introduction, and Basic JavaScript Instructions
read03 HTML Lists, CSS Boxes, JS Control Flow
read04 HTML Links, CSS Layout, JS Functions
read05 HTML Images; CSS Color & Text
read06 JS Object Literals; The DOM
read07 HTML Tables; JS Constructor Functions)
read08 More CSS Layout
read09 Forms and JS Events
read10 Debugging
read11 Audio, Video, Images
read12 Docs for the HTML <canvas> Element & Chart.js
read13 Local Storage
read14
read15