悬停在超链接上时,jQuery警报

时间:2018-11-30 08:18:09

标签: javascript jquery css html5

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

这是我到目前为止所拥有的:

<!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>

3 个答案:

答案 0 :(得分:2)

您没有关闭@else if $point == 1025 { @for $i from 1 through $columns { @media (min-width: $point + px) { $equ: 100% / ($columns)*$i; .col-#{$i} { width: $equ; } .offset-#{$i} { margin-left: $equ; } } } } 功能。 hover()之后的行应为:

alert(...)

注意括号之间的右括号。

答案 1 :(得分:2)

您的问题仅仅是JS中的一些包围问题。下面是修改后的代码:

var obj={};

knex.transaction(function(trx) {
  return Promise.map(array, function(item) {
        return trx.insert(item).into('table')
        .then(returnedFields => {
        //do some validation/operation and return the result or the returnedFields themselves as input in the next loop.
        //[START EDIT: this responds to comment by @ Mikael Lepistö for clarity]
        //update obj here to be used in next loop
        //[END EDIT]
      });
    }, {concurrency: 1});
})
.then(function(inserts) {
  console.log(inserts.length + 'Items saved.');
})
.catch(function(error) {
  console.error(error);
})

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

答案 2 :(得分:1)

您的逻辑是正确的,但有一个错字-您没有在alert()之后正确合上大括号

应该是-

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