score:2

Accepted answer

I have tried using ".tile div" instead ".tile" in calling func "highlightElem" .

 $(".tile div").on('click',function(){
    highlightElem($(this));
});

Also In "highlightElem" updated the code with "closest()"

function highlightElem(elem) {
if (oldElem !== null) {
    oldElem.closest('.widget').css("border-color", "#ccc");
}
elem.closest('.widget').css("border-color", "black");
oldElem = elem;

}

http://jsfiddle.net/vchbg/24/

Related Query

More Query from same tag