我有以下用于确认框的简单代码
<!DOCTYPE html>
<html>
<body>
<p>Click the button to alert the hostname of the current URL.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
confirm("Confirm!!!!");
}
</script>
</body>
</html>
但我的问题是我想用 css 以一种非常简单的方式设置确定和取消按钮的样式。我正在寻找一个真正简单的解决方案。
最佳答案
这个问题问的比较多:
回答; 您不能将 confirm() 函数设置为对话框样式,因为它是浏览器通用的。
您将不得不搜索如下替代方案:
- jQuery 盒子:onehackoranother.com/projects/jquery/boxy/
- jQuery 对话框:jqueryui.com/dialog/#modal-confirmation
您也可以尝试创建自己的对话框。这并不像您要求的那样简单。但是,可以找到很多教程:
- 教程 1: www.developphp.com/view.php?tid=1385
- 教程 2: tutorialzine.com/2010/12/better-confirm-box-jquery-css3/
(不好意思,初学者不能多放链接)
关于javascript - 一个非常简单的带有 css 的警告和确认框样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26962032/