As shown in the picture, only clicking on the yellow and blue areas will execute the function. Clicking on the red area and the green sub-elements within the red will not execute the function. How to write it with jquery?
为情所困2017-05-19 10:46:06
var _sel = true;
$(".red",".green").click(function{
_sel = false;
})
$('.yellow','.blue').click(function( ){
_sel = true;
})
if(_sel == true){
//Execute function
}
or
There is a public class to execute the function
$(class).click(funciton(){
//执行函数
})
Red and green do not have this class
迷茫2017-05-19 10:46:06
Finally, I first wrote a function that is executed when all elements are clicked. In the function, it is judged whether the className of the clicked element and the parent element of the element have the className. If it is true, the following content will not be executed
$(document).click(function(){
if(!(event.target.className==="red"||event.target.parents().hasClass('red')){
//执行相关操作
}
}