javascript - Add onclick to element, but keep current onclick event -
Is it possible to add a JavaScript event to a DOM element, which is already an onclick event, I want to keep the property
I have radio buttons like this:
& lt; Input type = "radio" name = "checkout-pay" value = "56" id = "checkout payment -56" square = "checkout-radio checkout-payment-radio checkout-payment-radio" onclic = "payment changed (this ); "/ & Gt;
I want to add
window.location.href = window.location.href
to the original onclick Keeping, but I do not have access to HTML, I can only modify it via javascript.
Therefore my desired code will be
& lt; Input type = "radio" name = "checkout-pay" value = "56" id = "checkout-payment -56" class = "checkout-radio checkout-payment-radio checkout-payment-radio" onclic = "payment changed ( It); Window Location.href = window.location.href "/>
wrap
window.location.href function In, call it onRadioButtonClick ()
then, just do it
var itself = this; // Keep the reference to file $ ("[name = checkout-payment]".) (Click 'on', call function () {onRadioButtonClick.call (self); // Call method with normal reference // Continue the code ..});
Comments
Post a Comment