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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:38:47+00:00 2026-05-28T05:38:47+00:00

Found a fiddle on stack, and played with it a tad to suit our

  • 0

Found a fiddle on stack, and played with it a tad to suit our needs.

But .. I need to the “tab” thats below the container div, to change text based on what state. ie. if open text should say close and vice versa and other element hidden.

I am guessing we should be able to add if else condition to js. Just a little stuck.

Fiddle here: http://jsfiddle.net/ozzy/zEcXp/

Code:js

$(document).ready(function(){
$("div#panel").show();

var autoTimer = null;

autoTimer = setTimeout(function(){
    $("div#panel").slideDown("slow");
    autoTimer = setTimeout(function(){
        $("div#panel").slideUp("slow");
    }, 5000);
},2000);

$("#open").click(function(){
    $("div#panel").slideDown("slow");
    if(autoTimer) clearTimeout(autoTimer);
    autoTimer = null;
});

$("#close").click(function(){
    $("div#panel").slideUp("slow");
    if(autoTimer) clearTimeout(autoTimer);
    autoTimer = null;
});         

});
code: html

<div id="widget">
 <div id="panel">Slidepanel<br />Slidepanel<br />Slidepanel</div>
  <div id="open">Open</div>
  <div id="close">Close</div>
</div>

code:css

#widget {position:relative;width:500px;height:100%;}
#panel{height:100px;background:#fafafa;border:1px solid #cccccc;z-index:1;}
#open {cursor:pointer;position:absolute;left:50%;
padding:0px 8px;
border-left:1px solid #cccccc;
border-right:1px solid #cccccc;
border-bottom:1px solid #cccccc;
border-top:1px solid #ffffff;
z-index:2;}
#open:hover ,#close:hover {color:#3399ff;}
#close {cursor:pointer;position:absolute;left:50%;bottom:0px;}

The code is very crude, I realise we can shortcut the css etc. But have done it this way so you can see the issue.
To recap, I am happy with the TAB position, just need to either show Open or Closed dependant on the Panel state. So only show Open tab and make it clickable if panel is closed and vice versa.

Cheers.

.ps just wondering if toggle would work better. But anyhoo.. lets fix this first

  • 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-28T05:38:47+00:00Added an answer on May 28, 2026 at 5:38 am

    I didn’t really understand what your whole timer stuff was about, but here is a simple means of sliding open/closed the panel and changing the message text. I bind to the click event of a single element, toggle_panel and then use jQuery’s slideToggle which handles hiding/showing the div. Finally I just do a simple check of the text inside slide_toggle. If it says ‘Closed’ then I change it to Open. Otherwise it must be Closed. This is called a ternary operator. If you want to be more clever you perhaps will want to check either the display state for determining text or storing the state using jQuery’s data method. I think this is the most straightforward for your use case though.

    http://jsfiddle.net/X9Vn4/79/

    $("div#panel").show();
    
    $("#toggle_panel").click( function() {
        $('#panel').slideToggle();
        $(this).html($(this).html() == 'Closed' ? 'Open' : 'Closed');                    
    });
    

    Another solution based on the fact that checking div visibility is more secure than checking contents of html

    $("#toggle_panel").click(function(){
        if ($("div#panel").is(':visible')) {
             $(this).html('Close');           
        }
        else {
             $(this).html('Open');                       
        }
        $("div#panel").slideToggle("slow");
        if(autoTimer) clearTimeout(autoTimer);
        autoTimer = null;
    });   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok found some great code on Stack. Have adapted it slightly. But in essence
Found this: Sub SurroundWithAppendTag() DTE.ActiveDocument.Selection.Text = .Append( + DTE.ActiveDocument.Selection.Text + ) End Sub But
I was given the script found here http://jsfiddle.net/b2Nq9/2/ but cannot get it to seem
I've found this Fiddle which does exactly what I'm after: http://jsfiddle.net/SYwpy/56/ with the exception
This is my fiddle: http://jsfiddle.net/7UwD2/ I've tried everything I found on the internet -
I have the following javascript code found also in this fiddle: http://jsfiddle.net/periklis/k4u4c/ <button id
I want a div content items interchange. I searched google and found this url:
Following on from a question I posted yesterday. Found here: Append different div id
http://jsfiddle.net/5DCZw/2/ i found this fiddle on the website here, and I cant figure out
It's probably very lame question, but I found no references in C# specification about

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.