###事件模拟
$("input").trigger("click");
####hover()
-格式 hover(fn1,fn2);等效 onmouseover+onmouseout
####动画
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../js/jquery-1.4.2.js"></script>
<style type="text/css">
img{
width: 200x;
height: 200px;
position: relative;
}
</style>
<script type="text/javascript">
$(function(){
$("input").click(function(){
if($(this).val()=="隐藏"){
$("img").hide(3000);
}else if($(this).val()=="显示")
$("img").show(3000,function(){
$("img").hide(3000,function(){
$("img").show(1000);
});
});
else if($(this).val()=="上滑"){
$("img").slideUp(3000);
}
else if($(this).val()=="下滑"){
$("img").slideDown(3000);
}
else if($(this).val()=="淡出"){
$("img").fadeOut(3000);
}
else if($(this).val()=="淡入"){
$("img").fadeIn(3000);
}
else{
$("img").animate({"left":"250px"},1000).animate({"top":"250px"},1000)
.animate({"left":"0"},1000).animate({"top":"0"},1000)
.animate({"width":"400px","height":"300px"},1000)
.animate({"width":"200px","height":"200px"},1000)
}
})
$('img').hover(function(){
$(this).animate({"width":"220px","height":"250px"},500),
function(){
$(this).animate({"width":"200px","height":"170px"},500)
}
})
})
</script>
</head>
<body>
<input type="button" value="隐藏">
<input type="button" value="显示">
<input type="button" value="上滑">
<input type="button" value="下滑">
<input type="button" value="淡出">
<input type="button" value="淡入">
<input type="button" value="自定义">
<hr>
<img alt="" src="../img/4.jpg">
</body>
</html>
jq基础知识
最新推荐文章于 2024-04-22 15:31:17 发布