tags:

views:

28

answers:

2

How can i check whether a button is clicked or not using javascript

+1  A: 

If you are talking about a <button>, use the onclick event. The dirty way to do so would be <button onclick="your javascript here">...</button>.

The clean way is registering an event handler from your javascript code. e.g. if you are using jQuery in this way:

$('#id-of-your-button').click(function(e) {
    e.preventDefault();
    /* do something */
});`

The preventDefault() call ensures no side-effects like submitting a form occur. When using the dirty inline way, you can achieve that by ending the code with return false;.

ThiefMaster
A: 

write alert in the function which you are calling so that u will get an bit idea

mehul9595