All jQuery Tips

How to make readonly textbox using Jquery

Sometimes making a textbox readonly is project need. There are 2 ways to make textbox readonly using jQuery. Method 1: <script type="text/javascript"> $(document).ready(function(){ $("#<%=txtName.ClientID %>").focus(function () { $(this).blur(); }); }); </script> See live Demo and Code Method 2: <script type="text/javascript"> $(document).ready(function(){ $("#<%=txtName.ClientID %>").attr('readonly', true); }); </script> Feel free to contact me for any help related […]
Read the rest of this entry »

jQuery – bind() vs live() vs delegate() methods

I had already posted about jQuery bind(), jQuery live() and  jQuery delegate() functions. All the three jQuery functions are used to attach events to selectors or elements. But just think why there are 3 different functions for same purpose? There can't be. right? So in this post, I will explain you how these functions are […]
Read the rest of this entry »

How to Disable right click using jQuery

You can find many java script code snippets to disable right click. But jQuery makes our life easy. Below jQuery code disables the right click of mouse. $(document).ready(function(){ $(document).bind("contextmenu",function(e){ return false; }); }); See live Demo and Code We just need to bind the contextmenu event with the document element. Method 2 (Send from one of the […]
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 »

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 »

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 »