www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
Methods
 click Method
click Method

Simulates a click by causing the onclick event to fire.

Syntax

object.click()

Return Value

No return value.

Remarks

Note  Simulating a click using the click does not bring the element being clicked into focus. (See example below).

Example

The following example demonstrates how simulating a click using the click does not, by default, bring the element into focus.

<HTML>
<HEAD>
<SCRIPT>
function simclick1()
{
chk1.focus(); //focus is explicitly set
chk1.click();
}
function simclick2()
{
chk1.click();
}
</SCRIPT>
<SCRIPT FOR=chk1 EVENT=onfocus>
alert("check box is in focus!");
</SCRIPT>
</HEAD>
<BODY>
<P STYLE="font-family:sans-serif;font-weight:bold">DEMO: USING CLICK METHOD 
DOES NOT SET FOCUS<P>
<UL STYLE="color:blue;font-family:sans-serif;font-weight:bold">
<LI>Both these buttons apply the click method to the check box. </LI>
<LI>An alert has been set to fire when the check box is put into focus. 
</UL>
</PLI>
<INPUT Type="CHECKBOX" id=chk1></INPUT>
<br>
<BUTTON >This button <B>applies the focus method</B> to 
check box</BUTTON>
<br><BUTTON >This button <B>does not apply the focus 
method</B> to check box</BUTTON>
<br>
</BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 World Wide Web link.

Applies To

A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, CUSTOM, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, hn, HR, I, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NOBR, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP
Tags What's this?: Add a tag
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG