10 examples of 'button onclick' in JavaScript

Every line of 'button onclick' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
10onClick() {
11 console.log('clicked');
12}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

116_onClick(event: Event): void {
117 const {
118 button,
119 onClick
120 } = this.props;
121 const {
122 enabled,
123 unclickable
124 } = button;
125
126 if (enabled && !unclickable && onClick) {
127 onClick(event);
128 }
129}
19onClick() {
20 const { onClick } = this.props;
21 onClick && onClick();
22}
62public onClick(event: React.MouseEvent<MouseEvent>) {
63 this.props.onClick ? this.props.onClick(event) : null;
64}
11onClick(event) {
12 const { disabled, onClick } = this.props;
13
14 if (disabled) {
15 event.preventDefault();
16 return;
17 }
18
19 if (onClick) {
20 onClick(event);
21 }
22}
11handleClick(event) {
12 const { onClick } = this.props
13 onClick(event)
14}
27handleClick(event) {
28 this.props.onClick(event);
29}
150onClick(event: any): void {
151 if (this.disabled) {
152 event.preventDefault();
153 event.stopImmediatePropagation();
154 } else {
155 this.click.emit(event);
156 }
157}
7onClick(e: SyntheticEvent<any>): void {
8 if (!this.props.loading) {
9 this.props.onClick && this.props.onClick(e);
10 }
11}
212onClick(event: MouseEvent) {
213 if (this.args.onClick) {
214 //throw error on console
215 assert(
216 'onClick of ember-elements must be a function',
217 typeof this.args.onClick === 'function'
218 );
219
220 // disabled button d'nt have a action
221 if (!this.disabled && this.args.onClick) {
222 this.args.onClick(event);
223 }
224 }
225}

Related snippets