Thursday, April 5, 2018

Attributes

The capability to set an attribute is very powerful; below, it turns an
input field into a button. Although not quite: we have changed the type, not the
object. This is what setting an attribute means: the attribute is having a
type, and that type is button. (Button objects are often of button type,
but not necessarily). Bottom line, our new button has the browser default
look of a button (Edge blue), but not the specific button style we have defined (salmon).


Here, we add an Event Listener to a button object. Note how 'click' and function
name are parameters in this approach.


The two approaches can be combined to make a new button fully functional.
This button responds first to onmouseover - and turns pink - then to the click event.



Finally, making sure to specify " use strict", the 'this' keyword can be used to cumulate
instructions on an element...



No comments: