简体   繁体   中英

Why my local javascript code is not being run on a local HTML 5 file?

The code is fully copied below.

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Avaliações</title>
    <script type="text/javascript" src="jquery-1.7.2-min.js" />
    <script type="text/javascript" src="jquery.xslt.js" />
</head>
<body>
    <script type="text/javascript">
        alert('123');
        $(function(){
            alert('affe');
            $('body').xslt({xmlUrl: 'xxx.xml', xslUrl: 'xxx.xsl'});
        });
    </script>
</body>
</html>

Why don't even the alerts work?

edit2: Nevermind, it was a typing error on my side when including jQuery... I realized it was something like this when the XLST plugin warned me about undefined jQuery and $.

Because using " /> " doesn't work for javascript. Unfortunately, you need to put

 <script type="text/javascript" src="jquery-1.7.2-min.js"></script>

for both your javascript files

Pretty sure <script> tags cannot use short form syntax. So

<script type="text/javascript" src="jquery-1.7.2-min.js" />
<script type="text/javascript" src="jquery.xslt.js" />

should be

<script type="text/javascript" src="jquery-1.7.2-min.js"></script>
<script type="text/javascript" src="jquery.xslt.js"></script>

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