简体   繁体   中英

JQuery plugins will not load

I have created a simple jquery example. On loading, the script should cause h1 tag to disappear from view, this however, is not happening.

I believe I have placed the scripts in the correct location, and in the right order. Please see below for markup and script:

<html>
<head>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script>
    <script src="test.js"></script>
    <link rel="stylesheet" href="style.css">
</head>
<body>

    <h1> JS</h1>

    <div id="top">
        <h1> JS</h1>
    </div>

    <section id="grid"> 
        <table
                <tr>
                    <td><a href="#">About</a></td>
                    <td><a href="#">Machinery</a></td>
                    <td><a href="#">Gallery</a></td>
                </tr>
        </table>
    </section>

</body>

${document}.ready(function() {

$("h1").hide();

$("td").click(function() {
    $(this).css("background-color","red");

    alert("you clicked!");
});

});

Looks like you have a couple of typos. Instead of curly brackets, document ready should be used like this in jQuery:

$(document).ready();

Also in your html you are not closing your opening <table> tag.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM