button onclick="" vs $(document).on("click",...)

554 views Asked by At

I have quite a curious case, regarding jquery and html. The HTML code for page is, as follows

<button id="button" type="button" onclick="doSmth()" accesskey="A"><u>A</u>ction</button>

and whenever i click accesskey - everything works just fine.

But - when I've tried to do exactly the same, just using the jQuery - simply adding

$(document).on("click","#button", doSmth)

and removing the "onclick" attribute of button - the page started to malfunction.
By saying "malfunction" mean that the click on the button still triggers the script, yet usage of the accesskey doesn't.
Is it just me, or that's the accesskey bug/feature ?

0

There are 0 answers