Jquery中实现动画后怎么改变字体

hopperhuang 2016-06-13 05:13:22

<!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>


想执行完这个动画后,该别ID为TEST的段落的文字,开始怎么弄都不行。
大大们教教我要怎么弄吧,我是新手。
...全文
165 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hopperhuang 2016-06-13
  • 打赏
  • 举报
回复
引用 7 楼 jslang 的回复:
[quote=引用 5 楼 baidu_23010771 的回复:] 为什么呢? 时不时JQUERY的代码不能跟平时的代码混用呢? 用了JQUERY的方法就要用JQUERY的写法,不能跟普通的方法混杂着写呢?
这要分清jquery对象和dom对象 http://www.jb51.net/article/23090.htm[/quote] 谢谢大神。
天际的海浪 2016-06-13
  • 打赏
  • 举报
回复
引用 5 楼 baidu_23010771 的回复:
为什么呢? 时不时JQUERY的代码不能跟平时的代码混用呢? 用了JQUERY的方法就要用JQUERY的写法,不能跟普通的方法混杂着写呢?
这要分清jquery对象和dom对象 http://www.jb51.net/article/23090.htm
天际的海浪 2016-06-13
  • 打赏
  • 举报
回复
$("#test")[0].firstChild.nodeValue = "I love you." ;
hopperhuang 2016-06-13
  • 打赏
  • 举报
回复
引用 4 楼 jslang 的回复:
getElementById
果然是打错字了。 再问一个问题,大神。 我把我的functi改成这样:

function() {
$("#test").firstChild.nodeValue = "I love you." ;
} 
为什么就不行呢? 但是

function() {
$("#test").text("I love you.");}
这样写却是可以的。 为什么呢? 时不时JQUERY的代码不能跟平时的代码混用呢? 用了JQUERY的方法就要用JQUERY的写法,不能跟普通的方法混杂着写呢?
天际的海浪 2016-06-13
  • 打赏
  • 举报
回复
getElementById
zpjshiwo77 2016-06-13
  • 打赏
  • 举报
回复
引用 楼主 baidu_23010771 的回复:
该别ID为TEST的段落的文字
这句话是什么意思? 你的代码没什么问题
引用
document.getElmentById("test") .firstChild.nodeValue = "I love you." ;
是吧id为test的元素的第一个子节点的值改为I love you. 不知道你的逻辑和页面结构是不是这样的。 然后你既然用了jquery其实也可以用jquery写的,这样写起来会简单一点: $("#test").children().first().test("I love you.")。
qq_23135645 2016-06-13
  • 打赏
  • 举报
回复
<!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的方法修改的文字,您看下
hopperhuang 2016-06-13
  • 打赏
  • 举报
回复
坐等大神们的指导啊,先谢大家了。 今天开始学Jquery,自己鼓捣一番,发现这个点搞不懂。

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧