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).
+6
A:
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.
Brandon Montgomery
2009-04-09 12:24:39
A:
From what I understand, you want to have multiple events mapped to the same element right?
Yes, it is possible. The order it will run might be a bit unpredictable, but you can have them.
fmsf
2009-04-09 12:28:58