【发布时间】:2022-06-21 21:42:03
【问题描述】:
我创建了一个引导按钮。单击按钮时,我希望它链接到另一个页面。我创建了一个名为 bitcoin.html 的页面。如何将主页的内容链接到我的 bitcoin.html 页面。锚标签似乎在引导按钮内创建了一个超链接——我不希望这样。我创建了一个 onclick 函数并尝试重定向它。但它不起作用。
function relocate {
location.href = "CRYPTOAPP/bitcoin.html"
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Cryptocurrency App</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;900&family=Ubuntu:wght@300;400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Cryptos To Watch 2022</h1>
<div class="container" id="crypocontainer">
<div class="card bitcoin" id="bitcoin">
<h1> Bitcoin </h1>
<img src="images/bitcoin.png" alt="bitcoin image">
<h2>Current Price </h2>
<h3 class="btc"> Btc</h3>
<button type="button" class="btn btn-success" onclick="relocate_bitcoin">Explore</button>
</div>
</body>
【问题讨论】:
-
你为什么不使用锚链接?这就是他们的目的。按钮不用于导航。
标签: javascript html jquery css twitter-bootstrap