[英]jQuery on list item hover, show delete button for that individual item
以下是我所擁有的預覽:
右邊是我徘徊的時候。 我想要的是刪除圖標僅針對該懸停項目顯示。
<script>
$(document).ready(function(){
$(".removeService").hide();
// Deleting an Individual Service
$("#dashboard ul li span").hover( function() {
$(".removeService").show();
});
});
</script>
這可能是一個非常簡單的解決方案,但是如果有人能指出正確的方向,我將非常感激。
謝謝!
如果希望刪除范圍僅在鼠標懸停時顯示,而在鼠標退出時隱藏,則可以通過提供第二個隱藏刪除范圍的函數來對.hover()
函數使用“重載”。
看到這個小提琴這里的一個例子。
一個非常簡化的示例如下所示:
$(document).ready(function(){
$('.remoteService').hide()
.click(function(){alert('delete!');});
$('#dashboard ul li span').hover(
function(){ //this is fired when the mouse hovers over
$(this).find('.remoteService').show();
},
function(){ //this is fired when the mouse hovers out
$(this).find('.remoteService').hide();
});
});
我希望這有幫助!
<script>
$(document).ready(function(){
$(".removeService").hide();
// Deleting an Individual Service
$("#dashboard ul li span").hover( function() {
$(this).find(".removeService").show();
});
});
</script>
假設.removeService
嵌套在#dashboard ul li span
。 如果不是這種情況,請提供您的html。
在代碼this
是實際span
這是上徘徊。 find
將在該范圍內搜索帶有removeService
類的所有元素。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.