jQuery: add border on hovered element but NOT parents
- by John Isaacks
I have this code:
var originalBorder = container.css("border");
container.hover(function(event) {
event.stopPropagation();
$(this).css("border", "1px solid "+options.color);
},function(){
$(this).css("border", originalBorder);
});
Which I am using to add a border to the currently hovered element. However for example if a span is inside a div they are both getting borders. I only want to target the span. I thought that adding event.stopPropagation() would do the trick (this is what I would do in Flex, which is what I am more used to) but I guess this is a live event which I dont even understand what that means. So basically how can target the youngest element without triggering the parents?
Thanks!!