收集几条jquery的实用技巧如下:
1) 检查IE是否是版本6
- if ( (jQuery.browser.msie) && (parseInt(jQuery.browser.version) < 7) ) {
-
$('body').prepend('<div class="warning">You are using an old version of Internet Explorer which is not supported. Please upgrade your browser in order to view this website.</div>');
- }
if ( (jQuery.browser.msie) && (parseInt(jQuery.browser.version) < 7) ) {
$('body').prepend('<div class="warning">You are using an old version of Internet Explorer which is not supported. Please upgrade your browser in order to view this website.</div>');
}
2) 打开一个打印的窗口
- [url=#]Print this page[/url]
-
$('a.print').click(function(){
- window.print();
-
return false;
- });
[url=#]Print this page[/url]
$('a.print').click(function(){
window.print();
return false;
});
3 禁止表单使用回车键
- $("#form").keypress(function(e) {
-
if (e.which == 13) {
-
return false;
- }
- });
$("#form").keypress(function(e) {
if (e.which == 13) {
return false;
}
});
4 全选和反选checkbox
- <div class="options">
- [list]
- [*][url=#]Select All[/url]
-
- [*][url=#]Reset All[/url]
-
- [/list]
-
-
<input type="checkbox" id="option1" /><label for="option1">Option 1</label>
-
<input type="checkbox" id="option2" /><label for="option2">Option 2</label>
-
<input type="checkbox" id="option3" /><label for="option3">Option 3</label>
-
<input type="checkbox" id="option4" /><label for="option4">Option 4</label>
- </div>
-
$('.select-all').live('click', function(){
-
$(this).closest('.options').find('input[type=checkbox]').attr('checked', true);
-
return false;
- });
-
-
$('.reset-all').live('click', function(){
-
$(this).closest('.options').find('input[type=checkbox]').attr('checked', false);
-
return false;
- });
<div class="options">
[list]
[*][url=#]Select All[/url]
[*][url=#]Reset All[/url]
[/list]
<input type="checkbox" id="option1" /><label for="option1">Option 1</label>
<input type="checkbox" id="option2" /><label for="option2">Option 2</label>
<input type="checkbox" id="option3" /><label for="option3">Option 3</label>
<input type="checkbox" id="option4" /><label for="option4">Option 4</label>
</div>
$('.select-all').live('click', function(){
$(this).closest('.options').find('input[type=checkbox]').attr('checked', true);
return false;
});
$('.reset-all').live('click', function(){
$(this).closest('.options').find('input[type=checkbox]').attr('checked', false);
return false;
});
5 平均分各个列
有的时候,需要在表格中让各个列等分,可以这样
- var max_height = 0;
-
$("div.col").each(function(){
-
if ($(this).height() > max_height) { max_height = $(this).height(); }
- });
-
$("div.col").height(max_height);
var max_height = 0;
$("div.col").each(function(){
if ($(this).height() > max_height) { max_height = $(this).height(); }
});
$("div.col").height(max_height);
6 将所有的连接用新建窗口打开
- $('a[@rel$='external']').click(function(){
-
this.target = "_blank";
- });
-
-
-
-
-
分享到:
相关推荐
资源名称:jQuery、jQuery UI及jQuery Mobile技巧与示例内容简介:《jQuery、jQuery UI及jQuery Mobile技巧与示例》包括jQuery、jQuery UI、jQuery Mobile以及jQuery插件四部分内容。第一部分介绍jQuery核心库,从...
JQuery实用方法大收集JQuery实用方法大收集JQuery实用方法大收集
jQuery 1.4给开发者带来了很多值得兴奋的新特性,同时使用jQuery的人也越来越多,为了方便大家对jQuery的使用,下面列出了一些jQuery使用技巧。比如有禁止右键点击、隐藏搜索文本框文字、在新窗口中打开链接、检测...
jQuery教程14个实用的jQuery技巧
JQuery实用方法大收集,里面含有jquery的技巧及其语法!
jquery实用教程,个人珍藏,望有缘人珍惜,并发扬光大!
jQuery技巧总结.pdf jQuery jQuery技巧
jQuery实用的手机充值选择效果
jQuery 应用技巧大全 实用技巧 很多技巧值得学习
jQuery应用技巧大全modified 猜想表白
spin.js是一款非常实用的jQuery Ajax loading spin旋转指示器插件。在页面进行ajax调用的时候,需要一个指示器来告诉用户当前正处于加载状态。该旋转指示器的作用就类似于一个无线循环的进度条。
jquery滚动条jquery滚动条jquery滚动条jquery滚动条jquery滚动条jquery滚动条jquery滚动条jquery滚动条jquery滚动条jquery滚动条jquery滚动条jquery滚动条jsDIV滚动条jsDIV滚动条jsDIV滚动条
NULL 博文链接:https://polokang.iteye.com/blog/563336
jQuery技巧,比较经典的几种用法总结。
jQuery 技巧大放送 jQuery 技巧大放送jQuery 技巧大放送 jQuery 技巧大放送jQuery 技巧大放送 jQuery 技巧大放送jQuery 技巧大放送 jQuery 技巧大放送jQuery 技巧大放送 jQuery 技巧大放送
jQuery技巧大放送很实用.doc jQuery技巧大放送很实用.doc