JQuery: adding an element to an event

Is it possible to add an element event in jQuery? For example, if I wanted to add the .fadeIn () element to the element when it is clicked, but also retain any other functions that may already exist (given that I don’t know if there is anything currently shooting when click).

+3
source share
2 answers

jQuery does not overwrite events, but adds to them. So, if you did this:

$(document).ready(function() {
    $("#test").click(function () { $(this).append("test<br />"); });
    $("#test").click(function () { $(this).append("test 2<br />"); });
});

with a div similar to:

<div id="test">click me <br /></div>

When you click on a div, it simultaneously adds “test” and “test 2”.

+6
source

As I understand it, do you want multiple events to be mapped to the same element?

, . , , , .

0

Source: https://habr.com/ru/post/1706176/


All Articles