<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
div {
width: 100px;
height: 100px;
background-color: skyblue;
position: relative;
left: 0;
}
</style>
</head>
<body>
<div id="box1">文字1</div>
<div id="box2">文字2</div>
<script src="./jquery-1.12.1.min.js"></script>
<script>
// jquery初体验
$('#box1').html('我是第一个div')
$('#box2').html('我是第二个div')
$('#box2').css({
'background':'pink',
'color':'blue'
})
//单击第一个div让他运动
$('#box1').on('click',function(){
$(this).animate({'left':'500'},1000);
$('#box2').animate(({'top':'500','left':'300'}),1000);
})
</script>
</body>
</html>
网友评论