Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Hide div / element if user signed in

422422 Developer MVP
edited December 2011 in Vanilla 2.0 - 2.8

Ok this is a html request but need some help please.

I have a div, and wish to hide that div if user is signed in.

@Todd did some code earlier, but not sure how to accomplish what I want. I suppose I would or could display:none but... anyhoo..


< script language="javascript">
                        jQuery(document).ready(function($) {
                        if (gdn.definition('SignedIn', '0') != '0') {
                            < div class="sp-container">
                                
                            < /div>
                        }
                        });
                        < /script>

I wish to hide content of sp-container if user not logged in. Tried using Todds code but I am pretty crap with js etc.

There was an error rendering this rich post.

Best Answer

  • Options
    x00x00 MVP
    Answer ✓
    $('.sp-container').hide();

    or

    $('.sp-container').css({'visibility':'hidden'});

    If you want to keep the space.

    grep is your friend.

Answers

  • Options
    sahotataransahotataran Developer, Bay Area - CA ✭✭✭

    Have ur div in page and in script in { } try something like

    $('.sp-container').css('display' , 'none');

    Or $('.sp-container').html(' '); to clear all content of div

    There was an error rendering this rich post.

  • Options
    x00x00 MVP
    Answer ✓
    $('.sp-container').hide();

    or

    $('.sp-container').css({'visibility':'hidden'});

    If you want to keep the space.

    grep is your friend.

  • Options
    422422 Developer MVP

    Brilliant thanks guys, I opted for .hide method. Thanks a million

    There was an error rendering this rich post.

Sign In or Register to comment.