[英]How do I get JQuery code to run on my browser?
我是JQuery的新手,我试图弄清楚如何使.mouseenter()和.mouseleave()方法正常工作。 到目前为止,我已经尝试使用IE8和FF,但是由于某些奇怪的原因,除了保持静态之外,我无法让元素做任何事情。 这是我到目前为止的代码:
HTML:
<!Doctype html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<script type="text/javascript" src="file:///D:/Documents%20and%20Settings/stsc/My%20Documents/_prac/script.js"></script>
<title>Practice</title>
</head>
<body>
<div id="red"></div>
<div id="yellow"></div>
<div id="green"></div>
</body>
</html>
CSS:
div{
height:100px;
width: 100px;
border-radius: 50px;
}
#red{
background-color: red;
}
#yellow{
background-color: yellow;
}
#green{
background-color: green;
}
JS:
$(document).ready(function(){
$('div').mouseenter(function(){
$(this).animate({
width: '+=10px'
});
});
$('div').mouseleave(function(){
$(this).animate({
width: '-=10px'
});
});
$('div').click(function() {
$(this).toggle(1000);
});
});
这只是使用JQuery进行练习的简单示例。 在此先感谢您的帮助!
您似乎没有包括jQuery:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
另外,D:\\驱动器是硬盘驱动器还是CD / DVD驱动器? 这也可能是一个问题。
您应该在HTML内引用jquery库:
<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="file:///D:/Documents%20and%20Settings/stsc/My%20Documents/_prac/script.js"></script>
<title>Practice</title>
</head>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.