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 6020879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:37:55+00:00 2026-05-23T03:37:55+00:00

To be more clear When you run the code —- click ‘show’ in the

  • 0

To be more clear When you run the code —- click ‘show’ in the page a div opens up with a gray background and another inner div with green background—onclick on gray background the div needs to close if we click on green div it should not close please help me out Thanks In advance.

I have a text ‘show’ onclick on show it open’s up a div which is set to display=none and this div is set to overflow=hidden. Inside the div I have a another div with matter. This works fine but the issue is onclick of the main div which is set to display=none has to close when it is click in its area.

code:

<html>
<head></head>
<script language="javascript"> 
function toggle(tId) {
 var ele = document.getElementById(tId);
       ele.style.display = "block";
}
function cancelToggle(id,e)

      {         var target = (e && e.target) || (event && event.srcElement);
        var obj = document.getElementById('toggleText');
        if(target!=obj){obj.style.display='none'}
      }
</script>
<body>

 <a id="displayText" href="javascript:toggle('toggleText');">show</a>

 <div id="toggleText" style="display: none; background: none repeat scroll 0 0 rgba(0, 0, 0, 0.6);  
            bottom: 0; height: 100%; left: 0; overflow: hidden; position: fixed; right:100; top: 10; width: 100%;">

    <div style="background: none repeat scroll 0 0 #80C5A9; display: block; height: 40%;
                position:fixed; bottom: 0;  overflow: hidden; width: 100%;">
   <h1>Welcome Naren</h1>
   <label>Its good for u.All the best</label> 
  </div>
 </div>

 </body>
</html>
  • 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-05-23T03:37:56+00:00Added an answer on May 23, 2026 at 3:37 am

    Does this work?

    <html>
        <head></head>
        <script language="javascript"> 
           function toggle(el) {
               if ( el.id && el.style.display == 'block' ) {
                  el.style.display = 'none';
               } else {
                  el.style.display = 'block';
               }
           }
    
        function cancelToggle(id,e)
    
             {         var target = (e && e.target) || (event && event.srcElement);
               var obj = document.getElementById('toggleText');
               if(target!=obj){obj.style.display='none'}
             }
    
        function stop() {
            if (event.stopPropagation) {
                event.stopPropagation();
            } else {
                window.event.cancelBubble = true;
            }
        }
        </script>
        <body>
    
        <a id="displayText" href="javascript:toggle(document.getElementById('toggleText'));">show</a>
    
        <div onClick='toggle(this)' id="toggleText" style="display: none; background: none repeat scroll 0 0 rgba(0, 0, 0, 0.6);  
                   bottom: 0; height: 100%; left: 0; overflow: hidden; position: fixed; right:100; top: 10; width: 100%;">
    
           <div onClick='stop()' style="background: none repeat scroll 0 0 #80C5A9; display: block; height: 40%; position:fixed; bottom: 0;  overflow: hidden; width: 100%;">
          <h1>Welcome Naren</h1>
          <label>Its good for u.All the best</label> 
         </div>
        </div>
    
        </body>
    </html>
    

    The other option is to examine event.target and see if the click came from inside the inner div.

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

Sidebar

Related Questions

Edit: Just wanted to make the question I have more clear. I pretty much
I am trying to create a VBA code that will run through each distinct
I'm working on yet another framework for PHP, and have run into a small
I am trying to test some code. The main script requires imports from a
There are a number of times I've run into a simple pattern when programming
Yesterday I discovered an odd bug in rather simple code that basically gets text
We're trying to run a set of administrative tasks on the server via a
I am not much clear with the Cross Platform Apps . Can we really
I've got a project which links to API level 11. When I run this
While working on a vb.net application, in which exceptions were handled poorly. It was

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.