87,901
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE>
<html lang ="en">
<head>
<meta charset = "utf-8" />
<title>For Test</title>
<script src = "script/jquery-3.0.0.js"></script>
<script>
$(document).ready(
function(){
$("div").click(
function(){
$("div").animate({
left:'20em',
opacity:'0.5',
width:'10em',
height:'10em'
},2000,function() {
document.getElmentById("test") .firstChild.nodeValue = "I love you." ;
} ) ;
}
);
}
);
</script>
</head>
<body>
<button type = "button">Cilck me </button>
<p id = "test" class = "test" >Have a try</p>
<p class = "test" > Have a test ,again.</p>
<p class = "test2" >I'm also a para.</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</body>
</html>
function() {
$("#test").firstChild.nodeValue = "I love you." ;
}
为什么就不行呢?
但是
function() {
$("#test").text("I love you.");}
这样写却是可以的。
为什么呢?
时不时JQUERY的代码不能跟平时的代码混用呢?
用了JQUERY的方法就要用JQUERY的写法,不能跟普通的方法混杂着写呢?<!DOCTYPE>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>For Test</title>
<script src="jquery-3.0.0.min.js"></script>
<script>
$(document).ready(function() {
$("button").click(function() {
$("div").animate({
left: '20em',
opacity: '0.5',
width: '10em',
height: '10em'
},function() {
$("#test").text("ffff");
});
}
);
}
);
</script>
</head>
<body>
<button type="button">Cilck me </button>
<p id="test" class="test">Have a try</p>
<p class="test"> Have a test ,again.</p>
<p class="test2">I'm also a para.</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</body>
</html>
我也是初学者,我用我的方法改了下
效果实现了
你的click按钮没有加上事件,我也帮你修改了一下
另外我用的jq的方法修改的文字,您看下