hi to all i have an interesting question
is it possible to copy onclick event of an element like this
$('#ElementId').attr('OldOnClick',$('#ElementId').attr('OnClick'));
Please guide me if there is any way of doing this.
i am trying to disable click event of all elements present on form at some point and on some other point i have to recover them so i am trying to save their onclick
with other attribute name
yes, you can access handler functions. The way of doing it in jquery would be this:
$('#specialbutton').click(function(){ console.log("peaches");};
var handlerFunction = $('#specialbutton').data("events").click[0].handler;
$('#specialbutton').click(); // "peaches"
handlerFunction(); // "peaches"
you would then assign it to another element like this:
$('#otherelement').click(handlerFunction);
$('#otherelement').click(); // "peaches"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With