Javascript jQuery中的问题?
我最近试图将交互式Javascript jQuery中的问题?,javascript,jquery,Javascript,Jquery,我最近试图将交互式div标记添加到我的HTML网站 为此,我使用了以下jQuery代码: $(document).ready(function() { $('div').mouseEnter() { $(this).fadeTo('fast', 0.5); $(this).animate ({ height:'+=10px' }); }); $('div').mouseLeave() {
div
标记添加到我的HTML网站
为此,我使用了以下jQuery代码:
$(document).ready(function() {
$('div').mouseEnter() {
$(this).fadeTo('fast', 0.5);
$(this).animate ({
height:'+=10px'
});
});
$('div').mouseLeave() {
$(this).fadeTo('fast', 1.0);
$(this).animate({
height:'-=10px'
});
});
});
我的网站已加载,但div
s未按要求运行
你能告诉我我的代码是否有错误吗
以下是html部分:
以下是:
JS:
我希望这有帮助 以下是:
JS:
我希望这有帮助 div的id或类名是什么?你确定你想说$('div')没有,我想所有的div都被影响好了,只是检查一下,确保我以前被它钉住了:)div的id或类名是什么?你确定你想说$('div')没有,我希望所有的div都会受到影响,好吧,只是检查一下,我之前已经被它钉住了:)我调整了编码,但它仍然不起作用,我再次检查了我是否在html文件中正确编写了脚本。我的计算机上是否需要安装任何特殊软件才能正常工作?@user3397648如果您在本地计算机上执行此操作,在链接到
.js
文件之前,您是否链接到了?@user3397648,您是否真的将jQuery包含到HTML中?我将其包含在正文中,我应该把它包括在报告中吗?我链接到jQuery文件是什么意思?很抱歉,我对这个主题缺乏了解,我对这种语言非常陌生,在使用任何其他标记之前先将它放到上。我调整了编码,但它仍然不起作用,我再次检查了我是否在html文件中正确编写了脚本。我的计算机上是否需要安装任何特殊软件才能正常工作?@user3397648如果您在本地计算机上执行此操作,在链接到.js
文件之前,您是否链接到了?@user3397648,您是否真的将jQuery包含到HTML中?我将其包含在正文中,我应该把它包括在报告中吗?我链接到jQuery文件是什么意思?很抱歉,我对这个问题缺乏了解,我对这门语言非常陌生,请先把它放到其他标签上。
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="main.js"></script>
<title>Dempsey Home</title>
</head>
<body bgcolor=black>
<link type="text/css" rel="stylesheet" href="stylesheet1.css"/>
<center>
<font>
<a name="TOP">
<h1>Kavanaugh Dempsey</h1>
<hr>
<table>
<tr>
<td>
<div onclick="location.href='index.html'">
<br><span><b>Home</b></span></a>
</div>
</td>
</a>
<td>
<div onclick="location.href='top5.html'">
<br><span><b>Top Five</b></span>
</div>
</td>
<td>
<div onclick="location.href='movies.html'">
<br><span><b>Movies</b></span>
</div>
</td>
<td>
<div onclick="location.href='movies.html'">
<br><span><b>Activities</b></span>
</div>
</td>
</tr>
</table>
</font>
</center>
</body>
</html>
div {
height:70px;
width:120px;
border-radius:10px;
color:#00FFFF;
background-color:#00FFFF;
border-color: #000000;
text-align: center;
opacity: 1;
}
span {
color: #000000;
text-decoration: none;
}
h1 {
font-family:Comic Sans MS;
}
font {
color:cyan;
font-family:Comic Sans MS;
}
$(document).ready(function() {
//`mouseEnter` is `mouseenter` and `mouseLeave` is `mouseleave`
$('div').mouseenter( function () { // some wrong was syntax here
$(this).fadeTo('fast', 0.5);
$(this).animate ({
height:'+=10px'
});
});
$('div').mouseleave(function () { // some wrong was syntax here
$(this).fadeTo('fast', 1.0);
$(this).animate({
height:'-=10px'
});
});
});