jQuery 常用技巧
来源:互联网 发布:任天堂vb算vr吗 编辑:程序博客网 时间:2024/06/08 13:23
1. 网页打开时,默认让某个指定元素获得焦点,应用场景(登录页面,让焦点在输入框内)
<body>
<input type="text" name="name">
<script type="text/javascript">
$(function() {
// 该触发器在触发事件的时候,会执行浏览器的默认行为
$('input').trigger('focus');
// 如果不想执行浏览器默认行为,使用 triggerHandler来取消
$('input').triggeHandler('focus');
});
</script>
</body>
2.动画里面使用 callback(回调函数)来延迟css的生效时间
<head>
<style type="text/css">
#panel {
position: relative;
width: 100px;
height: 100px;
border: 1px solid #0050D0;
background: #96E555;
cursor: pointer;
}
</style>
</head>
<body>
<div id="panel"></div>
<script type="text/javascript">
$(function(){
$('#panel').css('opacity', '0.5');
$('#panel').click(function(){
$(this).animate({left: "+=100px", opacity: '1'}, 2000)
.animate({height: '+=100px'}, 2000)
.animate({width: '+=100px'}, 2000, function(){
$(this).css('border', '5px solid blue');
});
})
})
</script>
</body>
0 0
- jQuery常用技巧
- jQuery 常用技巧总结
- 常用jQuery使用技巧
- jQuery常用技巧
- jQuery常用技巧
- jQuery常用技巧
- Jquery常用技巧
- jQuery 常用操作技巧
- JQuery常用技巧
- Jquery常用技巧
- jQuery常用技巧
- Jquery常用技巧
- jquery常用技巧
- jQuery常用技巧
- jQuery常用技巧
- Jquery常用技巧总结
- jQuery常用技巧总结
- JQuery 常用小技巧
- weebly外推软件
- linux下开启PHP 报错
- em的使用
- IMDB外推软件
- lex yacc 学习
- jQuery 常用技巧
- ng-class
- dpreview外推软件
- 让低版本浏览器兼容placeholder
- Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
- bandcamp外推软件
- 背包之01背包、完全背包、多重背包详解
- Java拦截器
- 数据链路层的负载均衡(Bonding)