出于某种原因,我正在调用的每个函数都不起作用.无论是"fadeOut","fadeIn"还是"fadeTo",我都会收到错误.
这是js脚本代码以及HTML.
<html>
<head>
<script type='text/javascript' src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<h1>Hello world</h1>
<ol>
<li> Hello</li>
<li> My </li>
<li> Name </li>
<li> is </li>
</ol>
</body>
</html>
$(document).ready(function(){
$('ol li').click(function(){
this.fadeOut('slow');
});
$('h1').click(function(){
this.fadeOut('slow',0.5);
});
$('li:nth-child(1)').mouseenter(function(){
('li:nth-child(2)').fadeOut('slow',0.25);
});
});
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下我做错了什么.
谢谢
你试图在不是jQuery的对象上调用jQuery方法.所以this变得$(this)等等
$(document).ready(function()
{
$('ol li').click(function()
{
$(this).fadeOut('slow');
});
$('h1').click(function()
{
$(this).fadeOut('slow',0.5);
});
$('li:nth-child(1)').mouseenter(function()
{
$('li:nth-child(2)').fadeOut('slow',0.25);
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2288 次 |
| 最近记录: |