Spidey
Spidey

Reputation: 2589

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 $.

Upvotes: 0

Views: 338

Answers (2)

russtuck91
russtuck91

Reputation: 604

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

Upvotes: 3

John Conde
John Conde

Reputation: 219844

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>

Upvotes: 2

Related Questions