慕数据5775487
2017-01-04 21:11
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title></title>
<script src="js/jquery-3.1.1.js"></script>
<style>
p {
color: red;
}
div{
width:200px;
height: 100px;
background-color: yellow;
color:red;
border:10 solid red;
}
</style>
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
</head>
<body>
<h2>animate(上)</h2>
<p>慕课网,专注分享</p>
<div id="aaron">内部动画</div>
点击观察动画效果:
<select id="animation">
<option value="1">动画1</option>
<option value="2">动画2</option>
<option value="3">动画3</option>
<option value="4">动画4</option>
<option value="5">动画5</option>
</select>
<input id="exec" type="button" value="执行动画">
<script type="text/javascript">
$('#exec').click(function(){
var v=$('#animation').val();
var $aaron=$('#aaron');
if(v=='1'){
$aaron.animate({
width:300,
height:300,
});
}else if(v=='2'){
// 在现有高度的基础上增加100px
$aaron.animate({
width:'+=100px',
height:'+=100px'
});
}else if(v=='3'){
$aaron.animate({
fontSize:'5em'
},3000,function(){
alert("动画 fontSize执行完毕!");
});
}else if(v=='4'){
$aaron.animate({
width: "toggle",
height: "toggle",
opacity: "toggle",
// border: "toggle"
},3000);
}else if(v=='5'){
$aaron.animate({
border: "toggle"
},2000)
}
});
</script>
</body>
</html>
你好,border里面含有 边框属性 和颜色属性 两个参数。这些属性如果不是数字的将不能使用基本的jQuery功能。老师已经讲过了。只能在原有边框的基础上改变边框的粗细。
例如:
<style>
div{
width:200px;
height: 100px;
background-color: yellow;
color:red;
position:relative;
border:1px solid red;
}
</style>
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
</head>
<body>
<input id="exec" type="button" value="执行动画">
<script type="text/javascript">
$("#exec").click(function(){
a.animate({
width:300,
height:300,
borderWidth:"4"
})
})所有用于动画的属性必须是数字的,你这里这么写 border: "toggle",这不是数值类型的。所以只能用borderWidth,borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth,borderSpacing
怎样用动画效果把边框显示出来?
border:10 solid red;这个没有单位,要写 10px
jQuery基础(四)—动画篇
85034 学习 · 268 问题
相似问题