jQuery has a lot of very useful plugins that can help you with almost anything, but there are a couple of plugins that aren’t that smart to use, why? Well sometimes 1 or 2 lines of jQuery code can do the same thing(or even better), so why use a big script if you can do the same trick with a small piece of code.
As many of you already know, jQuery can do a lot of things in more than just one way, so if you see a tip, trick or solution and think/know this can be done better, smarter or faster please let me know, post and share it in a comment below of just email me this, so that i can use this for part 2.
● Disable right-click(禁止右键点击)
Disable right-click contextual menu.
● Disappearing search field text(隐藏搜索文本框文字)
Hide when clicked in the search field, the value.(example can be found below in the comment fields)
● Opening links in a new window(在新窗口中打开链接)
XHTML 1.0 Strict doesn’t allow this attribute in the code, so use this to keep the code valid.
● Detect browser(检测浏览器)
Change/add something for a certain browser.
Notice: As of jQuery 1.4, the $.browser variable is replaced by $.support.
● Preloading images(预加载图片)
This piece of code will prevent the loading of all images, which can be useful if you have a site with lots of images.
● CSS Styleswitcher(页面样式切换)
Switch between different styles?
● Columns of equal height(列高度相同)
If you are using two CSS columns, use this to make them exactly the same height.
● Font resizing(动态控制页面字体大小)
Want to let the users change there font size?
● Smooth(animated) page scroll(返回页面顶部功能)
For a smooth(animated) ride back to the top(or any location).
● Get the mouse cursor x and y axis(获得鼠标指针 X/Y 值)
Want to know where your mouse cursor is?
● Verify if an Element is empty(验证元素是否为空)
This will allow you to check if an element is empty.
● Replace a element(替换元素)
Want to replace a div, or something else?
● jQuery timer callback functions(jQuery 延时加载功能)
Want to delay something?
● Remove a word(移除单词功能)
Want to remove a certain word(s)?
● Verify that an element exists in jQuery(验证元素是否存在)
Simply test with the .length property if the element exists.
● Make the entire DIV clickable(使整个 DIV 可点击)
Want to make the complete div clickable?
● Switch between classes or id’s when resizing the window(id 与 class 之间转换)
Want to switch between a class or id, when resizing the window?
● Clone a object(克隆对象)
Clone a div or an other element.
● Center an element on the screen(使元素居屏幕中间位置)
Center an element in the center of your screen.
● Write our own selector(写自己的选择器)
Write your own selectors.
● Count a element(统计元素个数)
Count an element.
● Use Your Own Bullets(使用自己的 Bullets)
Want to use your own bullets instead of using the standard or images bullets?
● Let Google host jQuery for you(引用 Google 主机上的 jQuery 类库)
Let Google host the jQuery script for you. This can be done in 2 ways.
● Disable jQuery animations(禁用 jQuery 动画效果)
Disable all jQuery effects.
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.