All Methods

jQuery Tip: How to Switch Css Class for elements

Have you ever come across a situation where you need to switch between two css classes for all the places where these classes are used? For example on click of button, you want to switch between class1 and class2. This can be easily achieved by jQuery. jQuery provides a method "switchClass" which allows you to […]
Read the rest of this entry »

How to Zoom an image using jQuery

You must had seen the zoom in and zoom out functionality for images on many sites. We can very easily achieve the Zoom In and Zoom Out functionality using jQuery toggle method. It is really simple. Let me first tell you the logic behind the implementation. Initially when document is ready then we will set […]
Read the rest of this entry »

width() vs css(‘width’) and height() vs css(‘height’)

jQuery provides two ways to set width and height of any element. You can set using css or you can use jQuery provided methods. If you want to set width to 100px then $('#dvText1').css('width','100px'); $('#dvText2').width(100); Then what is the difference? The difference lies in datatype. As its clear in code that with css method you […]
Read the rest of this entry »

How to use hover method in jQuery

In my earlier post, I have posted about how to provide highlight effect on mouseover and mouseout using jQuery events. Today, I found another solution which is easy and compact. jQuery provide hover() event which works for both the events. It works for mouseover and it also works for mouseout. Below jQuery code uses the […]
Read the rest of this entry »

How to highlight on mouseover using jQuery

In this post, I will show you a tip/trick to provide highlighting effect on mouseover and mouseout. For demo purpose, we will create a css class which will set the background color of element. This css class will be added to element on mouseover and it will be removed on mouseout. To achive this, we […]
Read the rest of this entry »

How to remove space from begin and end of string using jQuery trim

Below jQuery code remove spaces from begin and end of string using trim function of jQuery. $(document).ready(function(){ var strVal = " jQuery By Example "; strVal = jQuery.trim(strVal); alert(strVal); }); When you run this code, "jQuery By Example" will be displayed in alert box. trim() will remove the space from begin and end of any […]
Read the rest of this entry »

Responsive Menu
Add more content here...