As a learning task I'm trying to make a bit of a DOM element selector, similar to Firebug's. On mouse over of the element, I'll add a border to let the user know they're over an element. When they move away, it'll disappear.
I'm using this so far:
(I'll move to using .hover and .addclass further down the line). Anyway, this is all well and good, except it's adding the border to the moused-over element AND all of it's parents, as I guess technically I'm mouseovering all of them. I just want the single highest element. How do I do this?
I'm using this so far:
PHP:
$('*').mouseover(function () {
$(this).css("border", "2px solid #ff0000")
});
$('*').mouseout(function () {
$(this).css("border", "none")
});
(I'll move to using .hover and .addclass further down the line). Anyway, this is all well and good, except it's adding the border to the moused-over element AND all of it's parents, as I guess technically I'm mouseovering all of them. I just want the single highest element. How do I do this?