You should pay attention to your selectors :)

you have

$('baritem').click(function()

that looks for <baritem> DOM objects

but

$('#baritem').click(function()

will find <div id="baritem">




On Jan 5, 2:41 pm, Valerij <valeri...@gmail.com> wrote:
> This still wont work.. I've even tried copy your example character by
> character and it still gives nothing..
> I'm using this code onhttp://ferok.com/labs/test.htmlat the bottom
> bar, try clicking the "My Account" and the menu wont "pop up". I had
> this working before, but I didn't have this dynamic code which I can
> use to open more than just 1 "tab".
>
> The CSS:
> #stuff_menu {background-color:#E8E8E8;border: 1px solid #666666;bottom:
> 22px;display:none;left:0px;padding:5px 5px 1px 5px;position:
> absolute;width:200px;}
>
> On Jan 5, 5:03 pm, brian <zijn.digi...@gmail.com> wrote:
>
> > That works for me but I do see how this can be refactored:
>
> > <a id="stuff" class="baritem" href="#stuff_menu">My Account</a>
>
> > <div id="stuff_menu" class="SomeClass">
> >         <a href="##">My Account</a>
> >         <a href="##">More stuff</a>
> >         <a href="##">Here is a menu item</a>
> >         <a href="##">Here is a menu item</a>
> >         <a href="##">Here is a menu item</a>
> >         <a href="##">Here is a menu item</a>
> > </div>
>
> > Notice that I've changed the IDs so that the DIV has the link ID plus
> > some other string, rather than the other way around.
>
> > Also, I've added a class to the DIV to make it easier to set styles.
> > This isn't strictly necessary.
>
> > $(function()
> > {
> >         /* set up the onclick handler for all links on page load
> >          */
> >         $('.baritem').click(function()
> >         {
> >                 $('#' + this.id + '_menu').toggle();
> >                 return false;
> >         });
>
> > });
> > On Mon, Jan 4, 2010 at 4:01 PM, Valerij <valeri...@gmail.com> wrote:
> > > Hey guys, I'm trying to create 1 really simple function but it just
> > > doesn't work!
>
> > > function showMenu(menu) {
> > >        var menuid = $( "#"+menu );
> > >        var menuRoot = $( "#"+menu+"-root" );
>
> > >        menuid.toggle();
> > >        menuRoot.blur();
> > > }
>
> > > What this suppose to do is when you click a link, it will change
> > > settings of a specific div to "visible"
> > > The HTML:
>
> > > <a id="stuff-root" class="baritem" href="javascript:void(0)"
> > > onclick="showMenu('stuff');">My Account</a>
> > > <div id="stuff">
> > >        <a href="##">My Account</a>
> > >        <a href="##">More stuff</a>
> > >        <a href="##">Here is a menu item</a>
> > >        <a href="##">Here is a menu item</a>
> > >        <a href="##">Here is a menu item</a>
> > >        <a href="##">Here is a menu item</a>
> > > </div>
>
> > > Why doesn't this work? What am I doing wrong.. When I alert this, I
> > > get the correct div ids?

Reply via email to