Brett
Brett

Reputation: 31

JQuery Alert when hovering over hyperlink

I am trying to have an alert popup when I hover over a hyperlink. I am trying to use JQuery and Javascript. I am not sure what I am missing in my code currently. The hyperlink is in an anchor inside the main. Any help would be greatly appreciated.

This is what I have so far:

<!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="#">[email protected]</a>
        </footer>

    </div>
</body>

</html>

Upvotes: 0

Views: 678

Answers (3)

Gabriel Luci
Gabriel Luci

Reputation: 40898

You didn't close the hover() function. The line after alert(...) should be:

    })
  });

Notice the closing parenthesis between the braces.

Upvotes: 2

Tushar Walzade
Tushar Walzade

Reputation: 3809

Your logic is correct but there is a typo - you didn't close braces correctly after your alert().

It should be -

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

Upvotes: 1

Charlie
Charlie

Reputation: 530

Your problem is simply some bracketing issues in the JS. Below is the amended code:

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

Note: use F12 (dev tools) to find mistakes like these more easily

Upvotes: 2

Related Questions