Answer the question
In order to leave comments, you need to log in
How to track clicks on a specific element?
There is a map with location points on it. All points have the same general class "mark". I'm trying to make it so that when you click on a dot, the "active" class is added to it and the subtab appears. Here is the code:
$(function(){
$('.mark').click(function(){
if($('.mark.active').length < 1){
$('.mark').addClass('active');
$('.tooltip').fadeIn();
} else {
$('.mark').removeClass('active');
$('.tooltip').fadeOut();
}
});
});
Answer the question
In order to leave comments, you need to log in
.category-desc {
position: relative;
}
.page-header.item-title {
position: absolute;
bottom: 60px;
left: 10px;
}
You can use e.target or this:
$(function(){
$('.mark').click(function(){
var $mark = $(this); // или $(e.target)
if(!$mark.hasClass('active')) {
$mark.addClass('active');
$('.tooltip').fadeIn();
} else {
$mark.removeClass('active');
$('.tooltip').fadeOut();
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question