Archive for August, 2010

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 – 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 »

jQuery delegate method Example/Demo

With jQuery 1.4.2 launch, a new method called "delegate()" was introduced. This method attaches a handler to one or more events for selected/specified elements. Let's take an example. I have created a table and using delegate method, I will attach the click event handler to every td element. <table border="1" width="200px" cellspacing="5" cellpadding="5"> <tr> <td>Item […]
Read the rest of this entry »

How to Check element exists or not in jQuery

Have you ever thought that what will happen if you try to access an element using jQuery which does not exist in your DOM? For example, I am accessing "dvText" element in below code and that element does not exists in my DOM. var obj = $("#dvText"); alert(obj.text()); What will happen? There could be 2 […]
Read the rest of this entry »

Difference between jQuery parent() and parents() methods

In this post, we will see what is the difference between parent() and parents() methods. To understand this, let's look at the below given html code. <html> <body> <form id="form1" runat="server"> <div id="dvParent"> <div id="dvChild"> <p><span id="spnText">jQuery By Example Rocks!!!</span> </p> </div> </div> </form> </body> </html> As you see there 2 divs, 1 p and […]
Read the rest of this entry »

Call jQuery from ASP.NET server side

In this post, I will explain you that how can you call jQuery from server side in ASP.Net. Lets place a button on the page and on click of button, server side click event of button will get executed. <asp:Button ID="btnCall" runat="server" Text="Call jQuery From Server" OnClick="btnCall_Click" /> Server side click event of button. protected […]
Read the rest of this entry »