Answer the question
In order to leave comments, you need to log in
How to stop the event handler?
If you click icon1 then icon2 and map, then both map handlers work. How to stop icon1 event handler when icon2 is clicked?
$('.icon1').click(function(event){
$('.map').click(function(event){
console.log("from icon1");
});
});
$('.icon2').click(function(event){
$('.map').click(function(event){
console.log("from icon2");
});
});
Answer the question
In order to leave comments, you need to log in
var $map = $('.map');
$('.icon1').click(function(event){
$map.off('click');
$map.click(function(event){
console.log("from icon1");
});
});
$('.icon2').click(function(event){
$map.off('click');
$map.click(function(event){
console.log("from icon2");
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question