Developing interactive components for websites usually require the same code like equal div Height, Browser detection, preloading images, disabling right-click.. etc.

Yeah you guessed it right, today we gonna share some life saving jQuery snippets that will help you do simple tasks.
$(window).load(function() {
// Animate loader off screen
$("#loader").animate({
top: -200
}, 1500);
});
// where loader is <img src="download.png" id="loader">
//and first element to be loaded.
$('#foo').bind('click', function() {
alert('User clicked on "foo."');
});
$('#foo').bind('click', function() {
alert('User clicked on "foo."');
});
$('link[media='screen']').attr('href', 'Alternative.css');
$.expr[':']['nth-of-type'] = function(elem, i, match) {
var parts = match[3].split("+");
return (i + 1 - (parts[1] || 0)) % parseInt(parts[0], 10) === 0;
};
$(document).ready(function(){
$("ul > li").click(function () {
var index = $(this).prevAll().length;
});
});
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
$(document).ready(function(){
$(imageobj).attr('src', $(imageobj)
.attr('src') + '?' + Math.random() );
});
$(document).ready(function(){
$('a[href]').each(function() {
if((C = $(this).attr('href').match(/[.](doc|xls|pdf)$/))) {
$(this).addClass(C[1]);
}
});
});
$(document).ready(function(){
$('a[href]').each(function() {
if((C = $(this).attr('href').match(/[.](doc|xls|pdf)$/))) {
$(this).addClass(C[1]);
}
});
});
Hope this helps.
This entry was posted on Monday, January 2nd, 2012 at 4:20 pm
and is filed under
Tutorials .
You can follow any responses to this entry through the
RSS 2.0 feed.
You can leave a response, or trackback from your own site.