- 10 Jaw Dropping HTML5 and Javascript Effects http://bit.ly/auBD9g... 1 day ago
- 30 Clean and Simple Free Fonts http://bit.ly/bl9TcU... 3 days ago
- Follow me
When I start learning jQuery, I always look for a best way to implement a code. Or sometimes, look for the simplest solution among the rest, though it's not the elegant way to do it, but it's easy to understand. So, now, I'm gonna show you my favourite collection of jQuery tips and tricks
jQuery Cheatsheet from ColorCharge

jQuery Cheatsheet from Gscottolson WebBlog
jQuery Cheatsheet from From Far East WebBlog
$(document).ready(function() {
//write your code here
}
You can also do this, both are the same!
$(function(){
//write your code here
});
$('a[rel=external]').attr('target','_blank');
<a href="http://www.queness.com" rel="external">Queness in new window</a>
$("ul li").click(function(){
//get the url from href attribute and launch the url
window.location=$(this).find("a").attr("href"); return false;
});
<ul> <li><a href="home">home</a></li> <li><a href="home">about</a></li> <li><a href="home">contact</a></li> </ul>
$("a.cssSwitcher").click(function() {
//swicth the LINK REL attribute with the value in A REL attribute
$('link[rel=stylesheet]').attr('href' , $(this).attr('rel'));
});
<link rel="stylesheet" href="default.css" type="text/css"> ...... <a href="#" class="cssSwitcher" rel="default.css">Default Theme</a> <a href="#" class="cssSwitcher" rel="red.css">Red Theme</a> <a href="#" class="cssSwitcher" rel="blue.css">Blue Theme</a>
$(document).bind("contextmenu",function(e){
//you can enter your code here, e.g a menu list
//cancel the default context menu
return false;
});
$().mousemove(function(e){
//display the x and y axis values inside the P element
$('p').html("X Axis : " + e.pageX + " | Y Axis " + e.pageY);
});
<p></p>
$('#close').click(function(e){
e.preventDefault();
});
/* OR */
$('#close').click(function(){
return false;
});
<a href="#" id="close"></a>
$('#top').click(function() {
$(document).scrollTo(0,500);
}
<script type="text/javascript" src="js/jquery.scrollTo-min.js"></script> ...... <a id="top" style="cursor:hand;cursor:pointer"> Back to top
$(document).ready(function() {
setHeight('.col');
});
//global variable, this will store the highest height value
var maxHeight = 0;
function setHeight(col) {
//Get all the element with class = col
col = $(col);
//Loop all the col
col.each(function() {
//Store the highest value
if($(this).height() > maxHeight) {
maxHeight = $(this).height();;
}
});
//Set the height
col.height(maxHeight);
}
<div class="col" style="border:1px solid">Column One<br/> With Two Line<br/> And the height is different<br/><br/> </div> <div class="col" style="border:1px solid">Column Two<br/><br/></div>
//extend the jQuery functionality
$.extend($.expr[':'], {
//name of your special selector
moreThanAThousand : function (a){
//Matching element
return parseInt($(a).html()) > 1000;
}
});
$(document).ready(function() {
$('td:moreThanAThousand').css('background-color', '#ff0000');
});
$(document).ready(function(){
//ID, class and tag element that font size is adjustable in this array
//Put in html or body if you want the font of the entire page adjustable
var section = new Array('span','.section2');
section = section.join(',');
// Reset Font Size
var originalFontSize = $(section).css('font-size');
$(".resetFont").click(function(){
$(section).css('font-size', originalFontSize);
});
// Increase Font Size
$(".increaseFont").click(function(){
var currentFontSize = $(section).css('font-size');
var currentFontSizeNum = parseFloat(currentFontSize, 10);
var newFontSize = currentFontSizeNum*1.2;
$(section).css('font-size', newFontSize);
return false;
});
// Decrease Font Size
$(".decreaseFont").click(function(){
var currentFontSize = $(section).css('font-size');
var currentFontSizeNum = parseFloat(currentFontSize, 10);
var newFontSize = currentFontSizeNum*0.8;
$(section).css('font-size', newFontSize);
return false;
});
});
<a class="increaseFont">+</a> | <a class="decreaseFont">-</a> | <a class="resetFont">=</a> <span>Font size can be changed in this section</span> <div class="section1">This won't be affected</div> <div class="section2">This one is adjustable too!</div>
The effects and techniques demonstrated in tutorials on Queness can be used in whatever manner you wish without attribution. You cannot copy whole tutorials (unless permission is given), either in English or translated to another language.
Buy wholesale computers directly from China at DHgate.com
Discover the tools to build your e-Commerce Site with Netfirms
Buy China Products from Made-in-China.com
Cocktail Dresses
SmartPhone Cell Phone
Wholesale electronics
Web Hosting Rating
Buy WOW Gold
Get your cdl today
Debt collector review
Recent Comments