This is awesome post of AllThingsSmitty, it’s useful for anyone who are web developer.
Original article: https://github.com/AllThingsSmitty/jquery-tips-everyone-should-know
A collection of simple tips to help up your jQuery game.
- Checking If jQuery Loaded
- Back to Top Button
- Preload Images
- Checking If Images Are Loaded
- Fix Broken Images Automatically
- Toggle Classes on Hover
- Disabling Input Fields
- Stop the Loading of Links
- Cache jQuery Selectors
- Toggle Fade/Slide
- Simple Accordion
- Make Two Divs the Same Height
- Open External Links in New Tab/Window
- Find Element By Text
- Trigger on Visibility Change
- Ajax Call Error Handling
- Chain Plugin Calls
Checking If jQuery Loaded
Before you can do anything with jQuery you first need to make certain it has loaded:
if (typeof jQuery == 'undefined') {
console.log('jQuery hasn\'t loaded');
} else {
console.log('jQuery has loaded');
}