appending element and binding a mouseover event to same element
Hello
I came across an unexpected behavior:
I have the following markup
- <a href="#">hello</a>
and I run this javascript
- $('a')
.bind('mouseout', function(){
$(this).find("span[class*=pencil]").remove();
$(this).unbind('mouseout');
})
.append('<span class="pencil">pencil</span>')
.find('.pencil').click(function(){
console.log('pencil clicked');
})
the strange thing it that mouse over event execute even before the mouse hover the span.pencil element.
Is is a bug or is it a normal behavior.
by the way: there are no CSS appliend to any of the elements.
Thanks
Itay