mouseover should be bound as event that checks “if” statement each time mouse enters
a region of .input-medium, but “if” checks only 1 time. Of there would be no class and “if”
becomes false – hover will still be working.
I need to check if class exists each time.
$('.input-medium').on('mouseover' , function() {
if ($(this).attr('id') === 'error-highlight') {
$(this).hover(
function() {
$('<p class="reg-tooltip">test test</p>').appendTo('body');
},
function() {
$('p').remove();
});
}
});
Solution: Add the
ifcondition tohoveritself: