Why is my jQuery code not increasing the font size?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
a.test { font-size:40px; }
</style>
<script type="text/javascript" src="Scripts/jquery-1.4.1.js">
$(document).ready(function(){
$("a").addClass("test");
});
</script>
<title></title>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
</body>
</html>
If I write the style class within element a the font size increases, but not when I write it using jQuery. Am I missing something?
Thanks in advance.
You can’t use both a
srcvalue on a<script>tag and put scripts in it like you’ve done. Use a separate script tag for your code like this:When done right, you can see that the code works here: http://jsfiddle.net/jfriend00/ndvDs/