I am having a div when user hover on it will insert a div child div.
But the problem is on every hover it added the same div repeatably. so i tried the below script for check if child div availabe in MotherDiv do nothing. else add the Child div. These all are happen on hover. So, What is the wrong with the below code?
Am i missing something?
if ($('.MotherDiv').hasClass('Child'))
{
alert('alerady a div there!');//DO NOTHING
}
else
{
var Details= "<div class='MotherDiv'><table class='Special'><tr><td>Offers</td></tr><tr><td>CheckOut Now</td></tr></table></div>";
$(Child).insertAfter($(this));//This is insert the child div on hover
}
Are you looking for something like this. Simply adds new Child class if the div doesn’t have. If you need to add new child div inside mother div then you just have to customize the code a bit.
http://jsfiddle.net/ETuZB/3/