HTML Dom tutorial 19-html Dom Button Object

Source: Internet
Author: User

HTML Dom tutorial 19-html Dom Button Object

 

1: Button Object

The button object represents a button.

Each time a <button> tag appears in an HTML document, the button object is created.

2: properties of the Button Object
attribute description ie F O W3C
accesskey set or return the shortcut key for accessing a button. 6 1 9 Yes
disabled set or return whether to disable the button. 6 1 9 Yes
form Returns a reference to a form containing buttons. 6 1 9 Yes
id the ID of the set or return button. 6 1 9 Yes
name name of the set or return button. 6 1 9 Yes
tabindex set or return button's tab key control order. 6 1 9 Yes
type the Form Type of the return button. 6 1 9 Yes
value set or return the text displayed on the button. 6 1 9 Yes
3: Standard attributes
Property Description IE F O W3C
Classname Sets or returns the class attribute of an element 5 1 9 Yes
Dir Sets or returns the direction of Text 5 1 9 Yes
Lang Sets or returns the language code for an element 5 1 9 Yes
Title Sets or returns an element's advisory title 5 1 9 Yes

4: classname attributes

This example shows two methods to obtain the class attribute of the <body> element:

<HTML>

<Body id = "myid" class = "mystyle">

<SCRIPT type = "text/JavaScript">
X = Document. getelementsbytagname ('body') [0];
Document. Write ("body CSS class:" + X. classname);
Document. Write ("<br/> ");
Document. Write ("an alternate way :");
Document. Write ( Document. getelementbyid ('myid'). classname);

</SCRIPT>

</Body>

</Html>

Output:

Body CSS class: mystyle
An alternate way: mystyle

5. Other Properties

<HTML>

<Head>

<SCRIPT type = "text/JavaScript">
Function alertid ()
{
VaR TXT = "ID:" + document. getelementbyid ("mybutton"). ID

TXT = TXT + ", type:" + document. getelementbyid ("mybutton"). Type

TXT = TXT + ", type:" + document. getelementbyid ("mybutton"). Form
 

Alert (txt)
Document. getelementbyid ("mybutton"). Disabled = true

}

</SCRIPT>

</Head>

<Body>

<Form>
<Button id = "mybutton" onclick = "alertid ()"> click me! </Button>
</Form>

</Body>

</Html>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.