小编use*_*568的帖子

如何将 jquery 放在单独的文件中?

我在过去一个小时左右一直在谷歌搜索,但似乎无法找到解决这个问题的方法。我刚刚完成了 Codecademy 的 jQuery 课程,现在正在开发一个项目。由于某种原因,我的代码 jquery 代码将无法工作

jQuery:

$(document).ready(function(){
$("div").css("border", "3px solid red");
$(".storyblocks").mouseenter(function(){
    $(this).animate({
        height: "+= 20px"
        width: "+= 20px"
    });
});

$(".storyblocks").mouseleave(function(){
    $(this).animate({
        height: "-= 20px"
        width: "-= 20px"
    });
});
}); 
Run Code Online (Sandbox Code Playgroud)

HTML:

<!DOCTYPE html>
<html>
<head>
<title>Project Website</title>
<link type = "text/css" rel = "stylesheet" href = "stylesheet.css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>

</head>
Run Code Online (Sandbox Code Playgroud)

我添加了$("div").css("border", "3px solid red");检查 div 是否有红色边框,但到目前为止还没有运气。有人说我不需要 $(document).ready,但我不明白为什么不需要。

请帮忙?

html javascript css jquery

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×1

html ×1

javascript ×1

jquery ×1