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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:06:49+00:00 2026-05-27T12:06:49+00:00

I am using slidetoggle to open and close div, with easing using jquery. <script>

  • 0

I am using slidetoggle to open and close div, with easing using jquery.

<script>
 function toggleText() {
 $('#divToToggle').slideToggle("slow");
 if ($('#divToToggle').css('display') == 'none') {
      $('#aTag').html('Show');
 }
 else {
      $('#aTag').html('Hide');
 }
 }
</script>
<a id="aTag" href="javascript:toggleText();">
  Hide
</a>

The div it controls is <div id="divToToggle"></div>

Issue I have is onclick the text isnt changing , from Show to Hide and vice versa… I must be missing something very very simple..

Bugger also meant to ask, how do i attah a cookie to the event

  • 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-27T12:06:49+00:00Added an answer on May 27, 2026 at 12:06 pm

    Try this . This will work

    <script>
         function toggleText() {
              $('#divToToggle').slideToggle("slow", function(){
                 if ($('#divToToggle').css('display') == 'none') {
                     $('#aTag').html('Show');
                 }
                 else 
                 {
                     $('#aTag').html('Hide');
                 }    
           });    
         }
    </script>
    <a id="aTag" href="javascript:toggleText();">
          Hide
    </a>
    

    EDIT :
    Here is a simple function on how to set and delete a cookie – src –

      function setCookie(name,value,days) {
            if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
            }
            else var expires = "";
            document.cookie = name+"="+value+expires+"; path=/";
        }
    
        function getCookie(name) {
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
            }
            return null;
        }
    
        function deleteCookie(name) {
            setCookie(name,"",-1);
        }
    
       function toggleText() {
                  $('#divToToggle').slideToggle("slow", function(){
                     if ($('#divToToggle').css('display') == 'none') {
                         $('#aTag').html('Show');
                          deleteCookie('hiddendiv') 
    
                     }
                     else 
                     {
                         $('#aTag').html('Hide');
                         setCookie('hiddendiv',1,MENTOINYOURTIMEHERE)  
                     }    
               });    
             }
    
      $('aTag').click('toggleText');
      if(getCookie('hiddendiv'))
      {
        $('#divToToggle').hide();
      }
    
    <a id="aTag" href="javascript:toggleText();">
          Hide
    </a>
    <div id ="divToToggle"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this jQuery to hide a DIV: $(#slider).click(function() { $(.help).slideToggle(); $(#wrapper).animate({ opacity: 1.0
I have a div of which collapse and expands using slideToggle and easing. $('button').click(function
I am using the following sliding div script: http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html Currently, the slidetoggle function is
I'm using Soh Tanaka's script to toggle open and closed div content in the
I'm new to jQuery. I'm using .slideToggle to make a DIV appear at the
I'm just using a simple slideToggle function of jQuery. It works properly in my
I am using .slideToggle to open a panel when the user clicks a link:
I came across this great JQuery example of using a slidetoggle. I want to
I have multiple menus that are using .slideToggle (im learning jQuery currently). Using online
<?php echo(var answersC = answer-table-$qrow->id;); echo(var toggleC = toggle-table-$qrow->id;); ?> jQuery('toggleC').click(function() { jQuery('answersC').slideToggle('fast'); });

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.