8 个很有用的 jQuery 技巧(转)
http://www.oschina.net/question/12_145472
一个基于web的标签设计,打印工具,超diao
http://www.oschina.net/question/170775_145011
26个Jquery使用小技巧
http://www.cnblogs.com/xiaochao12345/p/3608208.html
1) 禁用鼠标右键点击
If you want to save your sites information from users, developers should use this code for disable Right clicking functionality. Using this code, jquery programmers can deactivate right clicking on web pages. Here are the code below: -
$(document).ready(function() {
//catch the right-click context menu
$(document).bind("contextmenu",function(e) {
//warning prompt - optional
alert("No right-clicking!"); //delete the default context menu
return false;
});
});
2) 更改文本字体大小
Using this code, users can re-size(increase and decrease) the text of websites. Users can increase and decrease fonts according to their requirement. Code is here: -
$(document).ready(function() {
//find the current font size
var originalFontSize = $('html').css('font-size'); //Increase the text size
$(".increaseFont").click(function() {
var currentFontSize = $('html').css('font-size');
var currentFontSizeNumber = parseFloat(currentFontSize, 10); var newFontSize = currentFontSizeNumber*1.2;
$('html').css('font-size', newFontSize);
return false;
}); //Decrease the Text Size
$(".decreaseFont").click(function() {
var currentFontSize = $('html').css('font-size');
var currentFontSizeNum = parseFloat(currentFontSize, 10); var newFontSize = currentFontSizeNum*0.8;
$('html').css('font-size', newFontSize);
return false;
}); // Reset Font Size
$(".resetFont").click(function(){
$('html').css('font-size', originalFontSize);
});
});
3) 在新窗口打开链接
Try this code and increase your site impressions because using this jquery code users will go on new window after clicking on any link of your site. Code is below: -
$(document).ready(function() {
//select all anchor tags that have http in the href
//and apply the target=_blank
$("a[href^='http']").attr('target','_blank');
});
4) CSS 样式切换
Swap style sheets using this code and the “Style sheets swap” script is below: -
$(document).ready(function() {
$("a.cssSwap").click(function() {
//swap the link rel attribute with the value in the rel
$('link[rel=stylesheet]').attr('href' , $(this).attr('rel'));
});
});
5) 返回页面顶部的链接
That is very common function you can see on eve site nowadays is ” Back to Top”. This functionality is very useful for long pages for make short in a single click. Visit this code below: -
$(document).ready(function() {
//when the id="top" link is clicked
$('#top').click(function() {
//scoll the page back to the top
$(document).scrollTo(0,500);
}
});
6) 获取鼠标指针当前的坐标
You can find the values of X and Y coordinator of mouse pointer. Code is blow : -
$().mousemove(function(e){
//display the x and y axis values inside the P element
$('p').html("X Axis : " + e.pageX + " | Y Axis " + e.pageY);
});
7) 检测当前鼠标的坐标
Using this script, you can find the current mouse coordinates in the any web browser supported jquery. Code is below: -
$(document).ready(function() {
$().mousemove(function(e)
{
$('# MouseCoordinates ').html("X Axis Position = " + e.pageX + " and Y Axis Position = " + e.pageY);
});
8) 预加载图片
this image preloading script helps to load image or web page very quickly. You not need wait to image load. The code is below:
jQuery.preloadImagesInWebPage = function()
{
for(var ctr = 0; ctr<arguments.length; ctr++)
{
jQuery("").attr("src", arguments[ctr]);
}
}
To use the above method, you can use the following piece of code:
$.preloadImages("image1.gif", "image2.gif", "image3.gif");
To check whether an image has been loaded, you can use the following piece of code:
$('#imageObject').attr('src', 'image1.gif').load(function() {
alert('The image has been loaded…');
});
8 个很有用的 jQuery 技巧(转)的更多相关文章
- 分享20款移动开发中很有用的 jQuery 插件
今天,很显然每个网站都需要有一个移动优化的界面以提高移动用户的使用体验.在开发任何移动项目时,要尽可能保持每一种资源尺寸都尽可能的小,以给最终用户提供一个好的体验是非常重要的.在这篇文章中我们已经编制 ...
- 对于 Web 开发很有用的 jQuery 效果制作教程
如果你的项目中需要响应式滑块,炫丽的图片呈现,对话框提示,轻巧动画等效果,jQuery 是完美的解决方案.凭借这个快速,易用的 JavaScript 库,可以轻松处理语言之间的交互,它给人最快速的 W ...
- 20+ 个很有用的 jQuery 的 Google 地图插件
转自:http://www.oschina.net/translate/20-useful-jquery-google-maps-plugins Google 地图在寻找我们想要了解的商店或者其它有趣 ...
- 20+ 个很有用的 jQuery 的 Google 地图插件 (英语)
20+ 个很有用的 jQuery 的 Google 地图插件 (英语) 一.总结 一句话总结:英语提上来我才能快速去google上面找资源啊.google上面的资源要比百度丰富很多,然后有了英语就可以 ...
- 20个很有用的CSS技巧
导语:下面这几个CSS技巧你可能不知道,1.彩色照片变黑白,2.所有元素垂直居中,3.禁用鼠标,4.模糊文字,小编学完能量满满的,觉得对CSS又充满了爱,你也来看看. 1. 黑白图像 这段代码会让你的 ...
- 【转】10 个很有用的 jQuery 弹出层提示插件
模态对话框为网站用户提供了快速显示信息的方法,也可以用来提示错误.警告和确认等信息,这里介绍了 10 个弹出模态对话框插件. How to Create a jQuery Confirm Dialog ...
- Css学习总结(1)——20个很有用的CSS技巧
1. 黑白图像 这段代码会让你的彩色照片显示为黑白照片,是不是很酷? img.desaturate { filter: grayscale(100%); -webkit-filter: graysca ...
- 分享十二个有用的jQuery代码
分享7个有用的jQuery代码 这篇文章主要介绍了7个有用的jQuery技巧分享,本文给出了在新窗口打开链接.设置等高的列.jQuery预加载图像.禁用鼠标右键.设定计时器等实用代码片段,需要的朋友可 ...
- 在网站开发中很有用的8个 jQuery 效果【附源码】
jQuery 作为最优秀 JavaScript 库之一,改变了很多人编写 JavaScript 的方式.它简化了 HTML 文档遍历,事件处理,动画和 Ajax 交互,而且有成千上万的成熟 jQuer ...
随机推荐
- ajax请求数据之后在已经有的数据前面打对勾的方法
今天遇到这么一个需求: 选择一部分人,在点击确定的时候添加到对应的div中,也就是添加到对应的表单下面,当再次查询的时候需要在已经选过的人的复选框前面打伤对勾.
- 牛客网暑期ACM多校训练营(第九场) A题 FWT
链接:https://www.nowcoder.com/acm/contest/147/A来源:牛客网 Niuniu has recently learned how to use Gaussian ...
- CodeForces 592D Super M
先把没用的边去掉,求出包含m个点的最小树.然后求出最小树的直径就可以得到答案了. #include <cstdio> #include <cstring> #include & ...
- Java面试题总结之OOA/D,UML,和XML
全文字数: 2732 阅读时间: 大约9 分钟 1.UML 是什么?常用的几种UML图? 统一建模语言(Unified Modeling Language,UML)又称标准建模语言:常用图包括 ...
- 获取鼠标位置的几个通用的JS函数
原文:http://www.open-open.com/code/view/1421401009218 /*两个通用函数,用于获取鼠标相对于整个页面的当前位置*/ function getX(e) { ...
- java 实现打印当前月份的日历
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcTc0NTQwMTk5MA==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- hdoj2680 Choose the best route
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission ...
- java里int类型转byte类型
今天在做书上的一个例子的时候, 要使用byte类型,首先我很直接的就写到了byte b = 0XAA, 结果报错, 说从int转换到byte可能会有损失. 我当时就很奇怪, 为什么会出现这种情况呢? ...
- 【iOS9系列】-3DTouch开发
[iOS9系列]-3DTouch开发 第一:简介 3DTouch 是iOS9系统系统下,在iPhone6s(iPhone6s Plus)手机上才能够使用的功能.熟练使用后,发现还是很便捷的. 但是模拟 ...
- 辛星浅析一次ajax的实现过程
说到ajax,那绝对是一个老生常谈的话题,近些年ajax技术的使用颇为盛行. 以下我们就以jQuery为例来从一个真实的项目中看一下ajax的实例. 首先是前端页面,这个页面我们使用的是bootstr ...