I have some div with its click actions and another div inside first – ‘close-cross’ on right-top corner witch close the first one or wherever else.
Problem is that when close-cross div is clicked, the main div click action is called too. Theoretically both are clicked, because the mouse button was pressed, and mouse pointer was above both divs, but I want only the div that is clicked directly to call its click event.
You want to use the
event.stopPropagation()method. This prevents events bubbling up the DOM tree. See the jQuery documentation here