I need to stop prevent default behavior of radio button to check if it checked before I click it or not, I'm using .live('click', function (){})
because the HTML added to DOM with AJAX
I need to stop prevent default behavior of radio button to check if it checked before I click it or not, I'm using .live('click', function (){})
because the HTML added to DOM with AJAX
- 1 Afaik, it is not possible to prevent default behavior from within a live handler. By the time it is run, the event already bubbled up and the default behavior executed. – Šime Vidas Commented Jul 25, 2011 at 17:10
- What default behavior specifically do you want to prevent? – Šime Vidas Commented Jul 25, 2011 at 17:31
-
You can disable the radio button and/or invert the checked property upon clicking. Ex:
radio.checked = !radio.checked;
. Afterwards, you can invert the checked property back if a certain criteria is met. – user1385191 Commented Jul 25, 2011 at 18:53 - Possible duplicate of preventing a user from changing the state of a radio button – Jessica Commented Aug 18, 2016 at 2:35
2 Answers
Reset to default 6Just return false;
from the handler.
Just return false
.live('click', function (){
return false;
})