Currently working on a straightforward menu that allows users to add new items. The issue arises when the user clicks on the last div ("new item"), causing a new item to be created and shifting the last item to the right, resulting in a flickering hover effect on the last item.
// locating elements
var button = $("button")
var container = $('.container');
var newBtn = $('.new');
newBtn.on('click', function() {
$('<div class="row">blinking new</div>').insertBefore(newBtn)
})
body {
margin: 0;
padding: 0;
}
.container {
display: flex;
background: gray;
height: 30px;
}
.row {
background: green;;
width: 100px;
}
.row:hover {
background: yellow;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="row">firstg </div>
<div class="row">second </div>
<div class="new row">new item</div>
</div>
Chrome: The background of the latest item blinks when the hover target changes.
IE11: When a new item is added, IE does not repaint the menu, resulting in the preservation of the hover state of the latest item even if the cursor is placed on the newly added item.
https://i.sstatic.net/6eQJu.gif
Is there any workaround available to resolve this issue?