Stackoverflow Response: Determining if a div was clicked on its border

http://stackoverflow.com/questions/16162649/determining-if-a-div-was-clicked-on-its-border/16166232#16166232

by Terry Young

HTML

<div class="A">
    This is div
</div>

<div class="B">
    This is div 2
</div>

<div id="log"></div>

CSS

div.A, div.B {
    background-color:yellow; 
    width:50px; 
    height: 50px;
    margin: 20px;
    padding: 10px;
    border-style: solid;
    border-color: red;
}
div.A {
    border-width: 10px 20px 30px 40px;
}
div.B {
    border-width: 50px 60px 70px 80px;
}

JavaScript

var $log = $('#log');
    
    $("div")
        .on('mouseout', function () { $log.empty(); })
        .on('mousemove click', function (event) {
            var $box = $(event.target),
                boxName = $box.attr('class'),
                box = {
                    offset: $box.offset(),
                    pos: $box.position(),
                    normal: {
                        // excludes padding
                        width: $box.width(),
                        height: $box.height(),
                    },
                    inner: {
                        // includes padding
                        width: $box.innerWidth(), 
                        height: $box.innerHeight(),
                    },
                    outer: {
                        // includes border
                        width: $box.outerWidth(),
                        height: $box.outerHeight()
                    },
                    border: {
                        // CAUTION: THIS ASSUMES THESE ARE IN PIXELS
                        left: parseInt($box.css('border-left-width'), 10),
                        right: parseInt($box.css('border-right-width'), 10),
                        top: parseInt($box.css('border-top-width'), 10),
                        bottom: parseInt($box.css('border-bottom-width'), 10)
                    }
                };
                
            $.extend(box, {
                inner: {
                    top: box.offset.top + box.border.top,
                    left: box.offset.left + box.border.left,
                    right: box.offset.left + box.border.left + box.inner.width,
                    bottom: box.offset.top + box.border.top + box.inner.height
                }
            });
        
            $.extend(box, {
                inner: {
                    mouse: {
                        top: event.pageY - box.inner.top,
                        left: event.pageX - box.inner.left,
                        right:...