gpt4 book ai didi

javascript - 将鼠标悬停在超链接上时发出 JQuery 警报

转载 作者:太空宇宙 更新时间:2023-11-03 20:26:19 26 4
gpt4 key购买 nike

当我将鼠标悬停在超链接上时,我试图弹出一个警报。我正在尝试使用 JQuery 和 Javascript。我不确定我目前的代码中缺少什么。超链接位于主链接内的 anchor 中。任何帮助将不胜感激。

这是我目前所拥有的:

<!DOCTYPE html>
<html lang="en">

<head>
<title>JavaJam Coffee House Music</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="javajam.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script>
$(document).ready(function () {
$('main a').hover(function () {
alert("Concerts sell out quickly so act fast!");
}};

</script>

</head>

<body>
<div id="wrapper">
<header>
<h1>JavaJam Coffee House</h1>
</header>
<nav>
<ul>
<li><a href="index.html">Home</a>;</li>
<li><a href="menu.html">Menu</a>;</li>
<li><a href="music.html">Music</a>;</li>
<li><a href="jobs.html">Jobs</a>;</li>

</ul>
</nav>
<main>
<div id="heroguitar">
</div>
<h2>Music at JavaJam</h2>
<p>The first Friday night each month at JavaJam is a special night. Join us from 8 pm to
11 pm for some <a href="#">music you won't want to miss!</a></p>
<h4>January</h4>
<div class="details">
<a href="melanie.jpg"><img src="melaniethumb.jpg" height="80" width="80" alt="Melanie Morris" class="floatleft"></a>
Melanie Morris entertains with her melodic folk style.
</div>
<h4> February</h4>
<div class="details">
<a href="greg.jpg"><img src="gregthumb.jpg" height="80" width="80" alt="Melanie Morris" class="floatleft"></a>
Tahoe Greg is back from his tour. New songs. New Stories.
</div>
</main>
<br>
<footer>
Copyright &copy; 2016 JavaJam Coffee House<br>
<a href="#">brett@banich.com</a>
</footer>

</div>
</body>

</html>

最佳答案

您的问题只是 JS 中的一些括号问题。下面是修改后的代码:

$(document).ready(function(){
$('main a').hover(function(){
alert("Concerts sell out quickly so act fast!");
});
})

注意:使用 F12(开发工具)更容易发现此类错误

关于javascript - 将鼠标悬停在超链接上时发出 JQuery 警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53553723/

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