I’m having a div which can have many (not less then 5) child elements (mostly they are div, table and img). I want to draw border (e.g. with jquery.css method) when a user clicked on any child element of that div. It can be easily done with something like
$div.click(function() {
//drawing frame here
});
Removing frame on click outside is much more harder. Of cause I can handle deselecting on click event thrown by any other div or body. But… maybe there’s more elegant solution?
Thank you in advance!
Try to use
.on('focusin')and.on('focusout')events to handle that.More info: focusin, focusout and .on();