Skip to Main Content
JavaScript: The Definitive Guide, Fourth Edition
book

JavaScript: The Definitive Guide, Fourth Edition

by David Flanagan
November 2001
Intermediate to advanced content levelIntermediate to advanced
936 pages
68h 43m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, Fourth Edition

Name

Button — a graphical push button

Availability

JavaScript 1.0; enhanced in JavaScript 1.1

Inherits from/Overrides

Inherits from Input, HTMLElement

Synopsis

                  form.button_name 
                  form.elements[i]

Properties

Button inherits properties from Input and HTMLElement and defines or overrides the following:

value

A string property that specifies the text that appears in the button. The value of this property is specified by the value attribute of the HTML <input> tag that creates the button. In browsers that cannot reflow document content, this property may be read-only.

Methods

Button inherits methods from Input and HTMLElement.

Event Handlers

Button inherits event handlers from Input and HTMLElement and defines or overrides the following:

onclick

Invoked when the button is clicked.

HTML Syntax

A Button element is created with a standard HTML <input> tag:

<form>
    ...
  <input
    type="button"          // Specifies that this is a button
    value="label"          // The text that is to appear within the button
                           // Specifies the value property
    [ name="name" ]        // A name you can use later to refer to the button
                           // Specifies the name property
    [ onclick="handler" ]  // JavaScript statements to be executed when the button
                           // is clicked
  >
    ...
</form>

Button objects can also be created with the HTML 4 <button> tag:

<button id="name"
        onclick="handler">
label
</button>

Description

The Button element represents a graphical push button in a form within an HTML document. The value property contains the text displayed by the button. The ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

John Pollock
Coding with JavaScript For Dummies

Coding with JavaScript For Dummies

Chris Minnick, Eva Holland

Publisher Resources

ISBN: 0596000480Supplemental ContentCatalog PageErrata