跳转到:

click 方法可以用来模拟鼠标左键单击一个元素。

当在支持click方法的元素上使用该方法时(比如<input>元素),会触发该元素的 click 事件。该事件会一直向文档树的上层元素冒泡,也会触发它们各自的click事件。但是,冒泡而来的事件会让一个 <a> 元素像受到真实的鼠标点击一样执行页面的跳转。

语法

element.click() 

规范

Specification Status Comment
Document Object Model (DOM) Level 2 HTML Specification Obsolete Initial definition

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 9
Notes
Full support 9
Notes
Notes Before Chrome 19, click is only defined on buttons and inputs.
Edge Full support YesFirefox Full support 3
Notes
Full support 3
Notes
Notes Before Firefox 5, click is only defined on buttons and inputs, and has no effect on text and file inputs.
IE Full support YesOpera Full support YesSafari Full support Yes
Notes
Full support Yes
Notes
Notes Before Safari 6, click is only defined on buttons and inputs.
WebView Android Full support Yes
Notes
Full support Yes
Notes
Notes Before Android WebView 4.4, click is only defined on buttons and inputs.
Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 5Opera Android Full support YesSafari iOS Full support Yes
Notes
Full support Yes
Notes
Notes Before Safari 6, click is only defined on buttons and inputs.
Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

文档标签和贡献者

标签: 
此页面的贡献者: zhuangyin, shiqianrongsx, Ende93, teoli, AshfaqHossain, jsx, ziyunfei
最后编辑者: zhuangyin,