视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
Jquery使用小技巧汇总_jquery
2020-11-27 21:48:04 责编:小采
文档


下面列出了一些Jquery使用技巧。比如有禁止右键点击、隐藏搜索文本框文字、在新窗口中打开链接、检测浏览器、预加载图片、页面样式切换、所有列等高、动态控制页面字体大小、获得鼠标指针的X值Y值、验证元素是否为空、替换元素、延迟加载、验证元素是否存在于Jquery集合中、使DIV可点击、克隆对象、使元素居中、计算元素个数、使用Google主机上的Jquery类库、禁用Jquery效果、解决Jquery类库与其他Javascript类库冲突问题。

1. 禁止右键点击



2. 隐藏搜索文本框文字
Hide when clicked in the search field, the value.(example can be found below in the comment fields)



3. 在新窗口中打开链接
XHTML 1.0 Strict doesn't allow this attribute in the code, so use this to keep the code valid.



4. 检测浏览器
注: 在版本jQuery 1.4中,$.support 替换掉了$.browser 变量



5. 预加载图片
This piece of code will prevent the loading of all images, which can be useful if you have a site with lots of images.



6. 页面样式切换



7. 列高度相同
如果使用了两个CSS列,使用此种方式可以是两列的高度相同。



8. 动态控制页面字体大小
用户可以改变页面字体大小



9. 返回页面顶部功能
For a smooth(animated) ride back to the top(or any location).



11. 获得鼠标指针XY值
Want to know where your mouse cursor is?



12. 验证元素是否为空
This will allow you to check if an element is empty.



13. 替换元素
Want to replace a div, or something else?



14. jQuery延时加载功能
Want to delay something?



15. 移除单词功能
Want to remove a certain word(s)?



16. 验证元素是否存在于jquery对象集合中
Simply test with the .length property if the element exists.



17. 使整个DIV可点击
Want to make the complete div clickable?



18. ID与Class之间转换.
当改变Window大小时,在ID与Class之间切换



19. 克隆对象
Clone a div or an other element.



20. 使元素居屏幕中间位置
Center an element in the center of your screen.



21. 写自己的选择器
Write your own selectors.



22. 统计元素个数
Count an element.



23. 使用自己的 Bullets
Want to use your own bullets instead of using the standard or images bullets?



24. 引用Google主机上的Jquery类库
Let Google host the jQuery script for you. This can be done in 2 ways.

[code]//Example 1
http://www.google.com/jsapi">

google.load("jquery", "1.2.6");
google.setOnLoadCallback(function() {
// do something
});
http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">

// Example 2:(the best and fastest way)
[/code">http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">[/code]

25. 禁用Jquery(动画)效果
Disable all jQuery effects



26. 与其他Javascript类库冲突解决方案
To avoid conflict other libraries on your website, you can use this jQuery Method, and assign a different variable name instead of the dollar sign.


 




下载本文
显示全文
专题