Wednesday, March 27, 2013

Difference in eq() and :eq() : becomes significant in case nested div

below : first eq(4) gives 4 div ( including the outer one), where as :eq(4) gives fourth INNER div
this needs to be investigated.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="eq.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <script language="javascript" src="jquery-1.7.2.min.js" type="text/javascript" ></script>
    <script type="text/javascript">
        function() {
        $("div").eq(4).click(function() { alert("789"); });
        $("div :eq(4)").click(function() { alert("000"); });
    <form id="form1" runat="server">
<script type="text/javascript">
    $("div").eq(2).click(function() { alert("123"); });
    $("div :eq(2)").click(function() { alert("456"); });

No comments:

Post a Comment