K''
K''

Reputation: 5228

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');
}

Upvotes: 4

Views: 1811

Answers (1)

Artem Kalinchuk
Artem Kalinchuk

Reputation: 6652

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

Upvotes: 8

Related Questions