ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

3 Essential jQuery Tricks That All Web Designers Need For Their Websites

Updated on June 24, 2011

3 Essential jQuery Tricks For Every Web Designer and Website Owner

These jQuery tricks make every webmaster's life easier and is used on almost all websites.
These jQuery tricks make every webmaster's life easier and is used on almost all websites. | Source

I use these on every website.

Let's face it. jQuery is changing the way web designers code and it makes our lives faster and easier. jQuery offers its plugin technology that allows developers to extend it and we get some pretty good programs to make web design much easier.

I have hubs on more jQuery and web design tricks as well including PHP, MVC, CodeIgniter, and CSS, so feel free to follow me for the tips and tricks to make your website design easier.

Before you delve into this hub, if you are not familiar with jQuery, read Blender's hub on the jQuery basics. It is really good.

jQuery Trick #1: Input Mask For Your HTML Forms

This cool jQuery plugin from Digital Bush allows you put symbols in your HTML forms for phone numbers, dates, social security numbers, etc that guides the user on how to enter them.

For example, if you have a phone number field, as soon as the user clicks into the phone number field, the phone number format automatically appears!

Where to download it:

How to enter this jQuery

  $("#phone").mask("(999) 999-9999");   

Advantages of using this plugin

You simply type 9's where the numbers would appear and the other symbols. The user cannot erase these symbols, so you get a perfect phone number every single time.

jQuery Trick #2: Equal Height Columns with jQuery

This jQuery trick is a must have and it solved the CSS issues of your different columns not having equal height, which seems to plague every web designer.

Do you know that situation when you have a background in your <DIV> tags and the background does not extend to the end of the column? This jQuery trick solves it.

You can view the full code at

Full sample HTML and jQuery

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS Newbie Example: Equal Height Columns with jQuery</title>
   body {
      font: small/1.3em Arial, Helvetica, sans-serif;
      background-color: white; }
   #wrap {
      width: 600px;
      margin: 0 auto; }
   .column {
      float: left; 
      padding: 10px; }
   #col1 {
      width: 110px;
      margin-right: 10px;
      background-color: #E2DDC4; }
   #col2 {
      width: 200px;
      margin-right: 10px;
      background-color: #6B99F6; }
   #col3 {
      width: 210px;
      background-color: #E87C5E; }
<script language="javascript" type="text/javascript" src="../../js/jquery/jquery.js"></script>
function equalHeight(group) {
   tallest = 0;
   group.each(function() {
      thisHeight = $(this).height();
      if(thisHeight > tallest) {
         tallest = thisHeight;
$(document).ready(function() {

<div id="wrap">
   <h1>Equal Height Columns with jQuery</h1>
   <p>This is an example of equal height columns using a single short jQuery function. View the page source or <a href="">refer to the original CSS Newbie article</a> to see how the function works.</p>
   <div class="column" id="col1">
      <p>This three-column design features three columns with significantly varying quantities of content.</p>
   <div class="column" id="col2">
      <p>However, despite the differing quantity amounts, these columns are exactly the same height. No tricks, no gimmicks, no resorting to repeating background images to fake our way to columnar nirvana. And certainly, no tables have been harmed in the making of these columns. </p>
      <p>They're simply divs sharing a common class, all of which have been set to the same height.</p>
   <div class="column" id="col3">
      <p>And I think a single class is an addition we can all get behind.</p>


Simple explanation of this Code

This is actually easier than it looks.

  1. Give all of your <DIV> tags a class called "column". The ID is up to you.
  2. Style your individual <DIV> tags any way you want with CSS.
  3. Enter the jQuery exactly as above.

That's it! Your columns will be equal height. I WISH I found this jQuery trick 3 years ago when I switched from table based design to tableless CSS.

jQuery Trick #3: Easiest Tooltip and Image Preview Using jQuery

According to the web page introducing this trick:What this script does is adds an element to the body when you roll over a certain object. That element's appearance is predefined with css (positioned absolute and styled) so all we need to do is fill the element with content, calculate mouse position and make it move accordingly. When cursor is moved over he object, element moves with it and when cursor roll out, the element is deleted.

You can get this at

This trick does not need code. Simply download the plugin.

Screenshot of Easy Image Preview

I will be adding more web design and jQuery tricks as I develop or find them.

If you would like to stay up to date on my jQuery tricks as I find them as well as other web design tricks, please let me know.


    0 of 8192 characters used
    Post Comment

    • hotwebideas profile imageAUTHOR

      Bruce Chamoff 

      7 years ago from New York

      Hey Blender, thanks for the feedback and jQuery tips. I am going to follow you back and read your jQuery hub that I just noticed.

    • blender profile image


      7 years ago from Vancouver, BC

      voted up and followed, thanks for the tips. You probably already know this one, and it is not directly related, but there is a css trick to stretch div's around floated content if you ever have that problem. Give the outer div a class including 'clearfix' and add this to your stylesheet:


      clear:both; content:"."; display:block;

      height:0; visibility:hidden; font-size:0;


      I can't take credit for this one, but use it on every site I make...

    • hotwebideas profile imageAUTHOR

      Bruce Chamoff 

      7 years ago from New York

      No problem, psychicdog. I have more jQuery tricks to write about in the near future, so stay tuned. I am now following you.

    • profile image 

      7 years ago

      thanks Hotwebideas - I'm always looking for better ways to do things on sites I build like where I have used jquery.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)