你的位置:首页 > 软件开发 > Java > 26个Jquery使用小技巧

26个Jquery使用小技巧

发布时间:2015-12-29 09:00:09
下面列出了一些Jquery使用技巧。比如有禁止右键点击、隐藏搜索文本框文字、在新窗口中打开链接、检测浏览器、预加载图片、页面样式切换、所有列等高、动态控制页面字体大小、获得鼠标指针的X值Y值、验证元素是否为空、替换元素、延迟加载、验证元素是否存在于Jquery集合中、使DIV可点 ...

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

1. 禁止右键点击

1

2. 隐藏搜索文本框文字

Hide when clicked in the search field, the value.(example can be found below in the comment fields)

1

3. 在新窗口中打开链接

XHTML 1.0 Strict doesn’t allow this attribute in the code, so use this to keep the code valid.

1

4. 检测浏览器

注: 在版本jQuery 1.4中,$.support 替换掉了$.browser 变量

1

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.

1

6. 页面样式切换

1

7. 列高度相同

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

1

8. 动态控制页面字体大小

用户可以改变页面字体大小

1

9. 返回页面顶部功能

For a smooth(animated) ride back to the top(or any location).

1

11. 获得鼠标指针XY值

Want to know where your mouse cursor is?

1

12. 验证元素是否为空

This will allow you to check if an element is empty.

1

13. 替换元素

Want to replace a div, or something else?

1

14. jQuery延时加载功能

Want to delay something?

1

15. 移除单词功能

Want to remove a certain word(s)?

1

16. 验证元素是否存在于jquery对象集合中

Simply test with the .length property if the element exists.

1

17. 使整个DIV可点击

Want to make the complete div clickable?

1

18. ID与Class之间转换.

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

1

19. 克隆对象

Clone a div or an other element.

1

20. 使元素居屏幕中间位置

Center an element in the center of your screen.

1

21. 写自己的选择器

Write your own selectors.

1

22. 统计元素个数

Count an element.

1

23. 使用自己的 Bullets

Want to use your own bullets instead of using the standard or images bullets?

1

24. 引用Google主机上的Jquery类库

Let Google host the jQuery script for you. This can be done in 2 ways.

1

25. 禁用Jquery(动画)效果

Disable all jQuery effects

1

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.

1

原标题:26个Jquery使用小技巧

关键词:jquery

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录