[英]I cannot get a piece of code to work outside of jsfiddle
我无法让这段代码在jsfiddle之外运行。 我不明白为什么它在我的本地服务器上不起作用。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.5.2.js'></script>
<style type='text/css'>
a, a:visited { color:black }
a.link.active { color:blue; }
</style>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(function() {
$('a.link').click(function() {
$('a.link').removeClass('active');
$(this).addClass('active');
});
});
});//]]>
</script>
</head>
<body>
<a href="#" class="link">Link 1</a>
<a href="#" class="link">Link 2</a>
</body>
</html>
我究竟做错了什么?
可能您没有将jQuery链接正确地包含到html中,请尝试将此行添加到您的头部:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.