首页 > 解决方案 > 在弹出的 html/js 中添加一个按钮

问题描述

大家好,我想在 html / js 中像这样的弹出式地图框上添加一个按钮,你能帮帮我吗

在此处输入图像描述

标签: javascripthtmlbuttonpopupmapbox

解决方案


你可以发布你的代码吗?至少是html代码。这应该在弹出窗口中添加按钮。

这类似于我认为您在图像中显示的内容。它被称为来自https://www.w3schools.com/css/css_tooltip.asp的工具提示。我添加了按钮的代码。没有您的代码,我们无法确切知道您在寻找什么。

<!DOCTYPE html>
<html>
<style>
.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  
  /* Position the tooltip */
  position: absolute;
  z-index: 1;
  bottom: 100%;
  left: 50%;
  margin-left: -60px;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}
</style>
<body style="text-align:center;">

<h2>Top Tooltip</h2>
<p>Move the mouse over the text below:</p>

<div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
  <button onclick="myFunction()">Click me</button>
</div>

</body>
</html>

你的 JavaScript:

function myFunction{
    alert("Add your code here");
}

推荐阅读