Top 15 jQuery Tricks

Sam Deering
Sam Deering
Share

I’ve found these very cool jQuery tricks for you. Some of them offer weird effects that are very entertaining and fun to use.

1. Image Cross Fade Transition

A basic trick to fade one image to another. Source: http://jqueryfordesigners.com/image-cross-fade-transition/

2. Background Image Animations

This offers easy to use jQuery Background Image animation effects. Source: http://snook.ca/archives/javascript/jquery-bg-image-animations/

3. Smooth jQuery popup

Create a polished jQuery popup using this trick.
Source: http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/

4. Fancy ShareBox

Create a partially hidden button that will be shown later when hovered. Source: http://www.jankoatwarpspeed.com/post/2009/07/13/Create-fancy-share-box-with-CSS-and-jQuery.aspx

5. Slick Tabbed Area

Have your contents tabbed! Source: http://net.tutsplus.com/tutorials/html-css-techniques/how-to-create-a-slick-tabbed-content-area/

6. Rounded Corners

With the help of jQuery Wrap, Prepend and Append functions. Creating rounded corner is possible. Source: http://docs.jquery.com/Tutorials:Rounded_Corners

7. Style Switcher

jQuery and PHP combination would create a clever style switcher. Source: http://net.tutsplus.com/tutorials/javascript-ajax/jquery-style-switcher/

8. jQuery Tools

This is a collection of six different and equally amazing tools for you to use in your website. https://www.sitepoint.com/wp-content/uploads/jquery4u/2011/01/jQuery-Plugins-jQuery-Tools.jpg
Source: http://flowplayer.org/tools/index.html

9. Chat Room

This is a team up of jQuery and PHP to build an interactive chat room. Source: http://css-tricks.com/jquery-php-chat/

10. News Ticker

Create a news ticker with fade it/out effects. Source: http://woork.blogspot.com/2009/05/how-to-implement-news-ticker-with.html

11. SlideViewer

This is a lightweight (1.5kb) jQuery plugin that creates an image gallery without requiring to write HTML codes. Source: http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html

12. Cheat Sheet

Tired of old looking plain jQuery Cheat Sheet? Check this out. Source: http://www.visualjquery.com/

13. Vertically Scrolling Menu

This is a basic but innovative vertical scrolling menu for your website’s navigation.
Source: http://www.queness.com/post/256/horizontal-scroll-menu-with-jquery-tutorial

14. Music Player

Create a fantastic jQuery music player with the help of xHTML. Source: http://yensdesign.com/2008/12/create-an-amazing-music-player-using-mouse-gestures-hotkeys-in-jquery/

15. Colour Fading Menu

This provides a good LavaLamp menu alternative menu. Color fades when hovered. Source: http://css-tricks.com/color-fading-menu-with-jquery/

Frequently Asked Questions (FAQs) about jQuery Tricks

What are some advanced jQuery tricks that can enhance my web development skills?

jQuery is a powerful tool that can significantly enhance your web development skills. Some advanced tricks include using the .on() method for event handling, using the .data() method to store information, using the .filter() method to narrow down a search, and using the .map() method to translate all items in an array or object to new array of items. Additionally, you can use the .end() method to end the most recent filtering operation in the current chain and return the set of matched elements to its previous state.

How can I optimize my jQuery code for better performance?

There are several ways to optimize your jQuery code for better performance. Firstly, you can cache your objects. This means storing the results of your jQuery selectors in variables for future use. Secondly, you can use IDs instead of classes for your selectors, as IDs are faster. Thirdly, you can chain your methods, which allows you to perform multiple operations on the same set of elements. Lastly, you can use the .on() method for event handling, which is faster and more efficient than the .click() or .bind() methods.

What are some common mistakes to avoid when using jQuery?

Some common mistakes to avoid when using jQuery include not caching objects, using the wrong selectors, not using method chaining, and not using the .on() method for event handling. Additionally, you should avoid using inline JavaScript, as it can make your code harder to manage and debug. Instead, you should use external scripts and load them at the bottom of your HTML document to improve page load speed.

How can I use jQuery to create animations on my website?

jQuery provides several methods for creating animations on your website. These include the .animate() method, which allows you to create custom animations, and the .fadeIn(), .fadeOut(), .slideUp(), .slideDown(), .show(), .hide(), and .toggle() methods, which allow you to create simple animations. To use these methods, you simply need to select the element you want to animate, call the method, and specify the duration of the animation.

How can I use jQuery to handle events on my website?

jQuery provides several methods for handling events on your website. The .on() method is the most powerful and flexible of these, as it allows you to attach one or more event handlers for specified events to selected elements. Other methods include the .click(), .dblclick(), .mouseenter(), .mouseleave(), .mousedown(), .mouseup(), .hover(), .focus(), .blur(), .change(), .select(), .submit(), .keydown(), .keypress(), and .keyup() methods.

How can I use jQuery to manipulate the DOM on my website?

jQuery provides several methods for manipulating the DOM on your website. These include the .append(), .prepend(), .after(), .before(), .remove(), .empty(), .clone(), .html(), .text(), .replaceWith(), .detach(), .unwrap(), .wrap(), .wrapAll(), .wrapInner(), .attr(), .removeAttr(), .prop(), .removeProp(), .addClass(), .removeClass(), .toggleClass(), and .css() methods.

How can I use jQuery to make AJAX requests on my website?

jQuery provides several methods for making AJAX requests on your website. The .ajax() method is the most powerful and flexible of these, as it allows you to make a full range of AJAX requests. Other methods include the .get(), .post(), .getJSON(), .getScript(), and .load() methods.

How can I use jQuery to work with forms on my website?

jQuery provides several methods for working with forms on your website. These include the .val(), .text(), .html(), .attr(), .prop(), .serialize(), .serializeArray(), .submit(), .reset(), .focus(), .blur(), .change(), .select(), and .trigger() methods.

How can I use jQuery to work with arrays and objects on my website?

jQuery provides several methods for working with arrays and objects on your website. These include the .each(), .map(), .inArray(), .grep(), .merge(), .makeArray(), and .extend() methods.

How can I use jQuery to work with cookies on my website?

While jQuery does not provide built-in methods for working with cookies, you can use the jQuery Cookie plugin to easily create, read, and delete cookies. This plugin provides the .cookie() method, which allows you to create and read cookies, and the .removeCookie() method, which allows you to delete cookies.