Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [jQuery] Make show/hide on anchor tags

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #29470

    Hey guys and gals,

    I’m trying to make a quite odd menu, but to finally achieve it I need to make show() and hide() to show my anchor tags as blocks, instead of the default inline. jQuery will always show/hide the a element as inline, but I need to be a block element. Any idea if this is possible?

    Thanks.

    #78847
    jamygolden
    Member

    what about .css("display", "none") and .css("display", "block")?

    #78874

    If I do it that way, I can’t add an effect to it. Or is it possible to do some sort of animate?

    #78882
    jamygolden
    Member

    It’s only displaying inline because that is what it’s original display was. If you change the display to block:

    Code:
    a { display: block; }

    Then it will display as a block again – once it is shown through show().

    #78889

    Ohh I see, thanks :) However, if I need them to be initially hidden (with display: none), how can I set it to display:block instead of display: inline when it appears back again?

    #78892
    jamygolden
    Member

    CSS:

    Code:
    a { display: block }

    start off your jQuery with:

    Code:
    $(document).ready(function(){
    $(“a”).hide();
    // insert other script here
    });
    #78895

    Thanks, sometimes I get lost in basic stuff :P Was trying to avoid .hide() that way, because it sometimes takes effect in front of the end user, resulting in a not so nice experience, but I’ll be using it anyways.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.