jQuery not working locally or via CDN

Associate
Joined
10 Feb 2009
Posts
1,893
Location
Leicester
Only get 3 results on google but can anyone help?

This is the code:

Code:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<style>
div {
	background-color: red;
}
a.test {
	font-size: 22px;
}
</style>
</head>

<body>

<script type="text/javascript">
$(document).ready(function() {
 $('a').addClass('a.test');
});
});
</script>

<div>
<p>some text</p>
</div>

<a href="asda">aa</a>

</body>
</html>

Should work right?

When I put in an alert message it works.. but when I try to code in jquery it doesn't .. :s
 
Last edited:
Aren't you missing the http from the cdn link?

PHP:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

PHP:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<style>
div {
	background-color: red;
}
a.test {
	font-size: 22px;
}
</style>
</head>

<body>

<script type="text/javascript">
$(document).ready(function() {
 $('a').addClass('test');
});
</script>

<div>
<p>some text</p>
</div>

<a href="asda">aa</a>

</body>
</html>

The http is missing so it works on both http and https (apparently), I just tried adding it and it still don't work.. the syntax change didn't make a difference either.. :confused:

edit:

adding http:// seems to of worked now along with changing a.test in the script to just 'test'.. local still not working though, think I need the jqueryUI for effects?
 
Last edited:
Back
Top Bottom