The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Simulates a click by causing the onclick event to fire.
![]() |
Syntax
object.click()Parameters
This method has no parameters.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Standards information
- Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5
Remarks
Note Simulating a click using the click does not bring the element being clicked into focus. (See example below).
Examples
The following example demonstrates how simulating a click using the click does not, by default, bring the element into focus.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/click.htm
<!DOCTYPE html> <html> <head> </head> <body> <p>DEMO: USING CLICK METHOD DOES NOT SET FOCUS<p> <ul> <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.</li> </ul> </p> <input type="checkbox" id="chk1"/> <br> <button onclick="simclick1()">This button <strong>applies the focus method</strong> to check box</button> <br> <button onclick="simclick2()">This button <strong>does not apply the focus method</strong> to check box</button> <br> <script type="text/javascript"> // When chk1 gets focus, pop an alert document.getElementById("chk1").addEventListener("focus", function(){alert("check box is in focus!");}, false); function simclick1() { chk1.focus(); //focus is explicitly set chk1.click(); } function simclick2() { chk1.click(); } </script> </body> </html>
See also
- a
- abbr
- acronym
- address
- applet
- area
- article
- aside
- b
- bdo
- big
- blockQuote
- body
- br
- button
- caption
- center
- cite
- code
- col
- colGroup
- custom
- dd
- del
- dfn
- dir
- div
- dl
- dt
- em
- embed
- fieldSet
- figcaption
- figure
- font
- footer
- form
- frame
- frameSet
- head
- header
- hgroup
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=file
- input type=hidden
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- ins
- isIndex
- kbd
- label
- legend
- li
- listing
- map
- mark
- marquee
- menu
- nav
- nextID
- noBR
- object
- ol
- optGroup
- option
- p
- plainText
- pre
- q
- rt
- ruby
- s
- samp
- section
- select
- small
- span
- strike
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- tr
- tt
- u
- ul
- var
- xmp
Send comments about this topic to Microsoft
Build date: 11/28/2012
