Archive for August, 2010

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 »

How to disable jQuery animation

In this post, you will find a simple jQuery tip to disable all animation. jQuery provides a property "jQuery.fx.off" which when set to true, disables all the jQuery animation. But why do you want to do that? Let's assume that you had written lots of jQuery code and you want to turn off all the […]
Read the rest of this entry »

How to set multiple CSS style using jQuery

In last post, I had explained how to select multiple element in single statement using jQuery. In this post, I will show you how can you set multiple CSS styles to any selector/element in single statement. Let's say you have a div tag and you want to set its background color to yellow, forecolor to […]
Read the rest of this entry »

How to select multiple elements in jQuery

Well, we all know how to select a single element in jQuery. $(document).ready(function(){ $("p").css('color','#FF0000'); }); But what if you come across a situation where you needs to apply some common functionality to multiple element. For example, you have couple of P tags, h1 tags and input boxes. You want to set their color to Red. […]
Read the rest of this entry »

jQuery Tip : Always load your jQuery framework from CDN

Here is a quick tip for the day. Always load your jQuery framework from Google, Microsoft or jQuery CDN(Content Delivery Network). As it provides several advantages. 1. You always use the latest jQuery framework. 2. It reduces the load from your server. 3. It saves bandwidth. jQuery framework will load faster from these CDN. 4. […]
Read the rest of this entry »