gpt4 book ai didi

php - 单击时如何使我的删除链接拆分为是/否?

转载 作者:搜寻专家 更新时间:2023-10-31 20:50:14 34 4
gpt4 key购买 nike

我有一个充满数据的表格,在行的末尾我有一个删除选项。

与其链接到一个全新的页面来确认删除,不如将“删除”链接拆分为一个是/否链接,根据单击的内容,删除行或变回“删除”,这样会很整洁。我知道 reddit.com 在他们的评论部分有一个很好的例子。

我试着寻找这个问题的答案,但我什至不知道如何调用它或用什么来完成它。

最佳答案

帮助其他 redditor 总是很有趣!

您可以做一些类似警报的事情,这样当元素被点击时它会发出警报并询问用户是否要确认。

if(confirm("Sure you want to delete this update? There is NO undo!"))

或者...

Reddit 有当你点击删除时会出现一个隐藏的元素

$('.delete_button').click(function(){

$('.delete_option').show();
$('.delete_button').hide();

});

如果您在更新数据库方面需要更多帮助或需要更多解释,请告诉我。

这是评论中jsfiddle的编码

HTML

<div id="delete">
<a href="#" id="delete_btn">delete</a>

<div class="option">
<span>are you sure?</span>
<a href=""> yes </a><span>/</span><a href=""> no</a>
</div>
</div>

CSS

a { 
text-decoration: none;
color: #888;
font-weight: bold;
font: normal x-small verdana, arial, helvetica, sans-serif;
}

.option {
display: none;
color: #888;
font-weight: bold;
padding: 0 1px;
font: normal x-small verdana, arial, helvetica, sans-serif;
}

.option span
{
color: red;
}

JQUERY

$('#delete_btn').click(function(){

$(this).hide();
$(this).next('.option').show();

});

关于php - 单击时如何使我的删除链接拆分为是/否?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8493673/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com