Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8269471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:14:12+00:00 2026-06-08T06:14:12+00:00

<body> <span id=lock>lock</span> <div id=one>test test</div> <div id=three style=display: none>hide</div> <span id=two>test</span> <div id=div_lock>

  • 0
<body>
    <span id="lock">lock</span>
    <div id="one">test test</div>
    <div id="three" style="display: none">hide</div>
    <span id="two">test</span>
    <div id="div_lock">
        Enter password: <input type="password"> <input type="button" value="unlock" id="unlock">
    </div>
</body>

$('#lock').click(function(){
  $('#div_lock').show();
    //????
})

$('#unlock').click(function(){
  $('#div_lock').hide();
//????
})

if i click LOCK then i would like open div_lock and hide all other elements in page. And if i click unlock then hide div_lock and show previous elements.

Can i use other function than .hide? If i use hide then is possible to check SOURCE code. Maybe any variables with SIMPLE hash etc?
If not how can i make this with .hide() and show()? I can use also PHP and Ajax

View the jsfiddle here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:14:13+00:00Added an answer on June 8, 2026 at 6:14 am

    The simplest solution is:

    $('#lock').click(function() {
        $(this).siblings().andSelf().fadeOut();
        $('#div_lock').fadeIn();
    })
    
    $('#unlock').click(function() {
        $('#div_lock').fadeOut();
        $(this).closest('div').siblings().fadeIn();
    })​
    

    (Though note I’m using fadeIn() and fadeOut() rather than the ‘more-sudden’ show() and hide())

    JS Fiddle demo.

    It’s also worth remembering that if anyone has access to your browser (assuming this is some kind of security feature) they can still override this via the JavaScript console, or by simply refreshing the page (assuming no log-in).


    Updated in response to comment left by OP (below):

    this is ok, but if i click unlock then this show me also <div id="three" style="display: none">hide</div> – this should me still display:none

    The problem you have is that all the affected elements are of style="display: none;" once the jQuery’s hidden them (that’s how it works, after all); so I’d suggest a tidier approach, and compartmentalising the content and the controls, to something resembling the following:

    <div id="controls">
        <button id="lock">Lock screen</button>
        <input type="password" />
        <button id="unlock">Unlock screen</button>
    </div>
    <div id="content">
        <!-- all content goes in here -->
    </div>​
    

    Which lends itself to the following jQuery (which stores the nodes to hide/show as they are, and then restores them as required):

    var content = $('#content'),
        contents;
    $('#controls').children().slice(1).hide();
    $('#lock').click(function() {
        contents = content.html();
        content.empty();
        $(this).hide().siblings().show();
    });
    
    $('#unlock').click(function() {
        content.html(contents);
        $(this).closest('div').children().hide().first().show();
    });​
    

    JS Fiddle demo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following div <body> <span style=border:1px solid red; display:inline-block> Some text<br />
The code is as below: <html> <head> <title>test</title> </head> <body> <div><span>shanghai</span><span class=margin> </span><span>male</span></div> </body>
Given the following XML structure <html> <body> <div> <span>Test: Text2</span> </div> <div> <span>Test: Text3</span>
Consider the following code: $(document).ready(function() { $(body).append(<div class='outer'><span class='inner'>Click me</span></div>); $(html).click(function(event) { var targetClass
var messageSpan; function createFlashMessage = function(message, type, time) { messageSpan || (messageSpan = $(<span>).hide().appendTo(body));
Are html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p,
I have just normalized the font size with this: html, body, div, span, applet,
Given the following HTML: <!doctype html> <html> <body> <span style=background-color: blue;> Some text here
Lets say i have the following web page: <html> <body> <div class="transform"> <span>1</span> </div>
I come across this: html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,d l,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,figure,footer,header,hgroup,menu,nav,section,menu,time,mark,audio,video{background:transparent;border:0;font-size:100%;list-style:none;margin:0;padding:0;outline:0;vertical-align:baseline;} The comment mention reset, I guess is used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.