开发者

Show delete button on mouseover and after delete remove li or div

开发者 https://www.devze.com 2023-02-02 06:24 出处:网络
In php code some english words are populating from database (postgr开发者_JAVA百科es) and put into li.

In php code some english words are populating from database (postgr开发者_JAVA百科es) and put into li. What I need is each li should have delete button which is hidden during load. When mouse is hover that image should be visible.

After that, delete operation will be performed on database side using ajax and that li will be removed.(no problem with it as I already coded).

I gone though this link, but instead of only button click event is fired for whole li block.I don't want this because in future I will add more button like edit,spam like that.

Same thing can be seen when you hover on comment you have made and delete icon will appear in stackoverflow.


jQuery will save your day.

<li>words <img src="delete.jpg" style="display:none;"/></li>

$('li').mouseover(function(event)
{
   $(this).find('img').show();
});

$('li').mouseout(function(event)
{
   $(this).find('img').hide();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消