In this post, I will list 10 random jQuery snippets I collected from all of my previous tutorial. If you always follow my tutorial you must be familiar with the following snippets, enjoy!
Traversing Each Element and Do The Same Action
This code will traversing each element that have a class and do the same action on each element. We’ve used this code on “How To Create iPhone-Style Navigation (Part I)” and “iPhone-Style Navigation:AJAX + Rotate (Part II)”
$('.additional-block').each(function() { //Do action });
Count Previous Siblings
Sometimes we need to count the previous siblings of selected element, we’ve used this code on “Create Animated Navigation Menu From Stratch“.
countPreviousItem = $(this).prevAll('element').length;
Animate Previous Element’s Parent
Just like above code this code we’ve used on “Create Animated Navigation Menu From Stratch“, we can animate or doing some action to the previous element’s parent from the selected element.
$(this).parents('element').prev('element').animate({ marginLeft: someFunctin }, 300);
Get Element’s Index Number
We can get element’s index number from its parent using following code, we’ve used this code on “Create Groovershark-like Widget Slider“.
indexNumber = $('element').index();
Get Checkbox Value
On “Stylize Your Own Checkboxes” and “[Code Snippet] jQuery : Checkbox & Table” posts we needed a code to check the checkbox is being checked or not, and we’ve used this following code.
checkboxValue = $('checkbox-element').attr('checked'); //OR checkboxValue = $('checkbox-element')[0].checked;
Count Element’s Padding
Count current element’s padding using this script, we’ve used this script on “Create Animated Navigation Menu From Stratch”
$('element').css('padding-left'); //OR another padding $('element').css('padding-top');
Does The Element Exists?
Before do some action to the selected element we can check its existance, does it exists or not. We’ve used this code on “[CodeSnippet] jQuery : Confirm User’s Action“.
if($(element).next('anotherElement').length <= 0) { //element doesn't exists; } else { //element exists; }
Inject Event Function on Any Additional Element
On “[CodeSnippet] jQuery : Confirm User’s Action” we also use this following code to inject an event function on any additional element we’ve added.
$('element').live('click', function(){ //Do some action });
Toggle The Function
On “iPhone-Style Navigation:AJAX + Rotate (Part II)” post, we’ve created a button toggle to rotate and rotate back the iPhone, here is the short code :
$('element').toggle( function() { //Rotate or do some action }, function() { //Rotate back or do some action } );
Toggle Mouseover and Mouseout
If we want to call different action when user mouseover or mouseout our element, we can use this following code that we’ve used on “How to create The Wire Tumblr in Realtime-alike“.
$('element').hover( function() { //When mouseover do some action }, function() { //When mouseout do some action } );
10 Random jQuery Snippet (via @hdytsgt)
[Community News] jQuery Fundamentals
RGraph : HTML5 Canvas Graph Library
jQuery Plugin : jQuery iPhone UI
Pikachoose : Another jQuery Plugin for Image Gallery
HTML5 Security Cheatsheet
[Community News] How to turn any jQuery plugin into a Wordpress one
Zoom Your Element Using Zoomooz.js
[Community News] Build a Flash-like Game With Scripty2
[Community News] CSS3 Transitions available on Firefox 3.7
[Community News] CSS from the Ground Up
- How To Create iPhone-Style Navigation (Part I)
This post has got 23 shouts so far - jQuery Plugin : jConfirmAction
This post has got 34 shouts so far - iPhone-Style Navigation:AJAX + Rotate (Part II)
This post has got 12 shouts so far - Simple Flip Puzzle Effect with jQuery
This post has got 6 shouts so far - Howto Create Mac-like Login Form
This post has got 7 shouts so far - Implement Password Strength Meter & Gauge.js
This post has got 8 shouts so far - Stylize Your Own Checkboxes
This post has got 15 shouts so far - Create Animated Navigation Menu From Stratch
This post has got 7 shouts so far
- Looks nice
by TheShadow on Filter Image View Using jQuery - Nice drop down menu tutorial.
by TheShadow on Simple CSS3 Dropdown Menu - love your site
by eJobsViet on Free Web UI Element Pack - @Andrew Ellis & @Hidayat Sagita take a look at this little test...
by Pomeh on jQuery Plugin : jConfirmAction - Hi, noob question, how do I use WebUI in WordPress and how do I use these...
by martin on Free Web UI Element Pack




10 Random jQuery Snippet | Webstuffshare.com – Worth Sharing … | Source code bank
[...] here: 10 Random jQuery Snippet | Webstuffshare.com – Worth Sharing … If you enjoyed this article please consider sharing [...]
Articles about design and examples – 21.04.2010 | DexTech
[...] 10 Random jQuery Snippet [...]
What Matters Today Blog Enlightment » 200+ More Useful Fresh Articles for Designers and Developers
[...] 10 Random jQuery Snippet [...]
10 Random jQuery Snippet | RefreshTheNet
[...] 10 Random jQuery Snippet | Webstuffshare.com — Worth Sharing Bookmarked Webstuff [...]
Pigeon
Is it just me or is the code for “Is The Element Exists?” wrong?
the condition says if the length of the element is less than or equal to 0 then it exists…
I believe that if length > 0 then element exists.
Also, the title is gramatically incorrect, it should read: ‘Does the element exists’
Hidayat Sagita
@Pigeon : Wow, sorry my bad
I’ve corrected the code, kudos for noticing
Also sorry for the grammatical error, i’m not native speaker and i’ll try my best
CSS Brigit | 10 Random jQuery Snippet
10 Random jQuery Snippet…
In this post, I will list 10 random jQuery snippets I collected from all of my previous tutorial. If you always follow my tutorial you must be familiar with the following snippets, enjoy!
…
Michael Pehl
Thanks for those useful snippets