try this instead
note my style is similar to that of a jquery plug in because i feel holding
elements in a variable makes it easier to work with eq();

var obj = $("#basictab ul li"); // reference point
var index = 0; // start tab
obj.eq(index).addClass("current"); // at class to start tab
/*
when you click any tab :
prevent default behavior
get the eq of the tab you just clicked
if the eq of that tab is not equal to the eq of the previous tab remove the
previous tabs class and add it to the current tab
*/
obj.click(function(e) {
e.preventDefault();
var current = obj.index($(this));
if(index != current) {
obj.eq(index).removeClass("current");
obj.eq(current).addClass("current");
index = current
}
});

On Tue, May 12, 2009 at 2:29 PM, Leonardo K <leo...@gmail.com> wrote:

> This $("a[href='Menu/appetizersandpizza.aspx']").addClass("current"); work
> for me... Look:
>
> http://jsbin.com/imoju/edit
>
>
>
> On Mon, May 11, 2009 at 18:15, Matt <matt.marc...@gmail.com> wrote:
>
>>
>> This seems like such a simple basic task, but I can't seem to get the
>> syntax correct.  I have a menu, and using jQuery it adds a class
>> (.current) to the link that corresponds to the current page.  This
>> works for all pages except the page in a subdirectory (link below
>> marked with a *).
>>
>>        <div id="menu" class="basictab">
>>          <ul>
>>                        <li><asp:hyperlink NavigateUrl="Default.aspx"
>> runat="server"
>> id="lnkDefault">Home</asp:hyperlink></li>
>>                        *<li><asp:hyperlink NavigateUrl="Menu/
>> appetizersandpizza.aspx" runat="server" ID="Hyperlink1">Menu</
>> asp:hyperlink></li>
>>                        <li><asp:hyperlink NavigateUrl="#" runat="server"
>> ID="lnkCatering">Catering</asp:hyperlink></li>
>>                        <li><asp:hyperlink NavigateUrl="Location.aspx"
>> runat="server" ID="lnkLocation">Location</asp:hyperlink></li>
>>          </ul>
>>        </div>
>>
>> Here is the jQuery call that I am using for the default.aspx page.
>>
>>     $("a[href='Default.aspx']").addClass("current");
>>
>> Here are a few of the different things I have tried for the link with
>> the submenu (obviously only one at a time).
>>
>>      $("a[href*=/Menu]").addClass("current");
>>      $("a[href='Menu/appetizersandpizza.aspx']").addClass("current");
>>      $("a[href*=/Menu]:first").addClass("current");
>>
>> Can anyone shed some light on what I can try (I'm still pretty new to
>> jQuery).  Thanks in advance.
>>
>
>

Reply via email to