jquery没有'不工作,可以'我在这里找不到正确的答案

jquery doesn't work, can't find the right answer here

本文关键字:找不到 在这里 答案 没有 工作 jquery 可以      更新时间:2023-09-26

我的带有jquery链接的html代码

<!DOCTYPE html>
<html>
    <head>
        <!-- metadata -->
        <meta charset="UTF-8">
        <meta name="keywords" content="bas webdesign, beverwijk, heemskerk, uitgeest, ijmuiden, velsen, noord holland, noord-holland, nederland, responsive webdesign, website bouwen, goedkoop, kwaliteit, betrouwbaar, html 5, css 3, javascript, huisstijl, huisstijlen">
        <meta name="viewport" content="width=device-width user-scalable=no">
            <!-- socialmedia -->
            <meta property="og:site_name" content="www.bas-webdesign.nl"/>
            <meta property="og:title" content="Investeer in je bedrijf, investeer in een goede website!"/>
            <meta property="og:description" content="Bas webdesign maakt websites op maat voor elk budget. Jij bepaalt, Bas maakt. Advies is bij Bas een service. En service is gratis, zoals het hoort! Neem gerust contact op en kom eens op de koffie voor een vrijblijvend gesprek."/>
            <meta property="og:image" content="afb/sociaal/socialeMediaThumbnail.jpg">
            <meta property="og:url" content="http://bas-webdesign.nl/">
            <meta property="og:type" content="Webdesign"/>
            <!-- socialmedia -->
        <!-- metadata -->

        <!-- links -->
            <!-- favicon -->
            <link rel="shortcut icon" href="afb/logo/favicon.png" type="image/x-icon">
            <link rel="icon" href="afb/logo/favicon.png" type="image/x-icon">
            <!-- favicon -->
            <!-- fonts -->
            <link href='http://fonts.googleapis.com/css?family=Josefin+Sans:400,700' rel='stylesheet' type='text/css'>
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
            <!-- fonts -->
            <!-- standaard -->
            <link rel="stylesheet" href="css/reset.css">
            <link rel="stylesheet" href="css/style.css">
            <!-- standaard -->
        <!-- links -->

        <!-- script -->
            <!-- jquery -->
            <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
            <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
            <!-- jquery -->
        <script src="js/actions.js"></script>
        <script src="js/smooth-scroll.js"></script> <!-- gebruik "data-scroll" in de a tag voor smoothscroll -->
        <!-- script -->

        <title>Bas Webdesign</title>
    </head>

    <body>
        <!-- omhuller -->
        <div class="omhuller">
            <!-- header -->
            <header id="header">
                <!-- logo -->
                <img src="afb/logo/logo.png">
                <!-- logo -->
                <!-- hoofdmenu -->
                <section id="hoofdmenu">
                    <ul>
                        <li>
                            <span id="menuIcoon_website" class="fa fa-globe" onmouseover="hoverAan(menuIcoon_website, menuTekst_website)"></span>
                            <a href="websites/" id="menuTekst_website" class="onzichtbaar" onmouseout="hoverUit(menuIcoon_website, menuTekst_website)">websites</a>
                        </li>
                        <li>
                        </li>
                        <li>
                        </li>
                        <li>
                        </li>
                    </ul>
                </section>
                <!-- hoofdmenu -->
            </header>
            <!-- header -->
        </div>
        <!-- omhuller -->

        <script>
            smoothScroll.init();
        </script>
    </body>
</html>

在这里我想开始我的悬停功能。

$( document ).ready(function() {
// globale variabelen
// globale variabelen

// functies
    // hover
        function hoverAan(onzichtbaar, zichtbaar){
            onzichtbaar.style.display = "none";
            zichtbaar.style.display = "inline";
        }
    // hover
// functies
});

问题是……如果没有jquery link and .ready()(如此简单的js),它确实可以工作。它是jquery链接的位置吗?还是我做错了什么?因为我想写很多CCD_ 2而不是CCD_。所以我想从一开始就确保它能完成任务。。现在却没有。

您希望将所有JavaScript函数都保留在$(document).ready(function () {});之外。这样,您的函数将与HTML一起加载,而不是在加载HTML之后再加载。