How to determine what is clicked on the desired item?

var alerte = $('.alerte.active'); 
$('body').on('click', function(e)
{
 if (alerte.has(e.target).length===0) {}
});

trying to determine, but it doesn't work on normal.
How to make that always worked and when klikaesh on the item itself and when the child elements.

I have it check for a condition and not a separate function on click of the item.
April 4th 20 at 00:50
2 answers
April 4th 20 at 00:52
$('body').on('click', '.alerte.active', function() {
 // do something
});

Even better - do not hang up events on the body.
$('.alerte.active').on('click', function(e)
{
 // do something
});


How to make that always worked and when klikaesh on the item itself and when the child elements.

The way it works.
so no I don't, it's one of the conditions, and I need to make it a condition that can be checked. - dorothea.Bechtelar commented on April 4th 20 at 00:55
@dorothea.Bechtelar, well then look at the event.target
- Alvah_Ritchie68 commented on April 4th 20 at 00:58
@Alvah_Ritchie68,
<div class="alerte active">
<span></span>
</div>

doesn't work if you clinet on the child span - dorothea.Bechtelar commented on April 4th 20 at 01:01
@dorothea.Bechtelar, as well) Must look the target in the priest. And why the condition should be?
- Alvah_Ritchie68 commented on April 4th 20 at 01:04
@Alvah_Ritchie68because conditions triggering a few and the check is for multiple conditions and so convenient it turns out, the different functions click create - dorothea.Bechtelar commented on April 4th 20 at 01:07
@dorothea.Bechtelar, well, at least you can not cling to the body? And then every time you click - all of your conditions will be checked. And look at that, and somehow I'm not sure that will be more convenient)
Here is an option:
- Alvah_Ritchie68 commented on April 4th 20 at 01:10
April 4th 20 at 00:54
You're trying to catch a pop-up event for the elements. Here, read it. That was not such a problem, use what you suggested @Alvah_Ritchie68 in the second embodiment. The only thing is, there is a caveat, in the presence of several such logic elements may (remember that this is still js) to break, so best to check on the length of elements with this set of classes and each give a tracking event click. Well, or hang directly in the html onclick.

If the problem is still in a deep setting, I recommend to go back to the link to the article about pop-up events and the interception, they were at the beginning of this response. Or read how it is done by the means of jQuery, because, as I understand the syntax is it (not the fact, for the fashion at the record through $ went on it).

Find more questions by tags JavaScriptjQuery