Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between onclick and click in javascript

Is there any kind of difference between the following two lines of code in javascript:

<button id='btn1' onclick='do_this();'>Button 1</button>;

<button id='btn1' click='do_that();'>Button 2</button>;

//some script later
function do_this()
{
    alert('this');
}

function do_that()
{
    alert('that');
}
like image 855
K'' Avatar asked Feb 23 '23 14:02

K''


1 Answers

onclick works in javascript, click doesn't. If you want click to work, you might need jQuery.

like image 198
Artem Kalinchuk Avatar answered Mar 04 '23 22:03

Artem Kalinchuk