Is it possible in jQuery to add an element's event? For example if I wanted to add a .fadeIn() to an element when it is clicked but also retain any other functionality that may already exist (given that I do not know if there is or isn't currently anything firing on click).
jQuery doesn't overwrite events, it adds to them. So if you did:
$(document).ready(function() {
$("#test").click(function () { $(this).append("test<br />"); });
$("#test").click(function () { $(this).append("test 2<br />"); });
});
with a div looking like:
<div id="test">click me <br /></div>
When you click on the div, it will append "test" and "test 2" at the same time.
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