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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:04:44+00:00 2026-06-17T19:04:44+00:00

Basically my issue is that my tooltip won’t change text on toggle. I have

  • 0

Basically my issue is that my tooltip won’t change text on toggle. I have a page with expand/collapse functionality. Normally, when you hover over the up arrow, the title tag will say collapse panel. When you click the arrow button to collapse the div panel, the img changes (now the arrow will point down and the title tag should change to expand panel). This works and the title changes WITHOUT tooltips. When tooltips are added, the text doesn’t change. I believe you have to destroy and create a new tooltip on click but I’m not sure how to do this. He’s my code, thanks in advance.

$("img.toggle1").click(function(){
  if (document.getElementById("panel1").style.display != "none") { // is the div hidden?
    $("img.toggle1").attr("src", "images/expander-down.png");
    $("img.toggle1").attr("title", "Expand this section");
     }
  else{ // is the div showing?
    $("img.toggle1").attr("src", "images/expander-up.png");
    $("img.toggle1").attr("title", "Collapse this section");
    $('div#header1').addClass('headerBarFirstOff');
  }
    $("div.panel1").slideToggle("slow");

  });

So update with the destroy/create method. I can get the tooltip to change to expand on the first click, but it stays as “expand”. I used this:

$("img.toggle1").click(function(){
  if (document.getElementById("panel2").style.display != "none") {
    $("img.toggle1").attr("src", "images/expander-down.png");
    $(document).tooltip("destroy"); //here's the change, the tooltip toggles once
    $(document).tooltip(); //here's the change, the tooltip toggles once
    $("img.toggle1").attr("title", "Expand this section");
     }
  else{
    $("img.toggle1").attr("src", "images/expander-up.png");
    //$(document).tooltip("destroy"); //doesn't work here
    //$(document).tooltip(); //doesn't work here
    $("img.toggle1").attr("title", "Collapse this section");
  }

Also, I have checkboxes (that hide/show specific panels) and buttons that open or close all:

$(document).ready(function(){
$("input.togglePanel1").click(function(){
  if($(".togglePanel1").length == $(".togglePanel1:checked").length) { 
    $("div.panel1").slideDown("slow");
    } else {  
    $("div.panel1").slideUp("slow");
    }
  });
$("input.togglePanel2").click(function(){
  if($(".togglePanel2").length == $(".togglePanel2:checked").length) { 
    $("div.panel2").slideDown("slow");
    } else {  
    $("div.panel2").slideUp("slow");
    }
  });
$("input.togglePanel3").click(function(){
  if($(".togglePanel3").length == $(".togglePanel3:checked").length) { 
    $("div.panel3").slideDown("slow");
    } else {  
    $("div.panel3").slideUp("slow");
    }
  });

$("img#closeAll").click(function(){
    $("div.panel1").slideUp("slow");
    $("div.panel2").slideUp("slow");
    $("div.panel3").slideUp("slow");
    $("div.panel4").slideUp("slow");
    $("div.panel5").slideUp("slow");
  });
$("img#openAll").click(function(){
    $("div.panel1").slideDown("slow");
    $("div.panel2").slideDown("slow");
    $("div.panel3").slideDown("slow");
    $("div.panel4").slideDown("slow");
    $("div.panel5").slideDown("slow");
  });
  • 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-17T19:04:45+00:00Added an answer on June 17, 2026 at 7:04 pm

    You can set tooltip text manually using the uiTooltipTitle data attribute

    $("img.toggle1").click(function(){
      var ishidden = $('#panel1').is(':hidden');
      var src = ishidden ? "images/expander-down.png" : "images/expander-up.png"
      var title = ishidden ? "Expand this section" : "Collapse this section";
      $("img.toggle1")
               .attr("src", src);
      $("img.toggle1")
               .attr("title", title)
               .data('uiTooltipTitle', title);      
      $("div.panel1").slideToggle("slow");
    
      });
    

    http://jsfiddle.net/SHBWW/

    Using if/else

    $("img.toggle1").click(function(){
        if($('#panel1').is(':hidden')){
            $("img.toggle1").attr("src", "images/expander-down.png");
            $("img.toggle1")
               .attr("title", "Expand this section")
               .data('uiTooltipTitle', "Expand this section");  
        }else{
            $("img.toggle1").attr("src", "images/expander-up.png");
            $("img.toggle1")
               .attr("title", "Collapse this section")
               .data('uiTooltipTitle', "Collapse this section");  
        }       
        $("div.panel1").slideToggle("slow");    
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue that I'm basically baffled by. To start off, I have
I'm seeing basically the same issue described here I have a table that starts
I am stuck with a peculiar issue here. I have a script that basically
I'm trying to debug an issue that is really stumping me. Basically, I have
Technically I'm using fadeToggle() but they're cousins... basically my issue is that I have
I have a small issue that I don’t really know how to solve, basically
I have this issue that I can't seem to get my head around... Basically
I've come across a weird issue that I've spent ages working on. I'm basically
I'm having an issue with rails involving javascript. Basically, I have the following code:
http://jqueryui.com/demos/autocomplete/ Basically my issue is that when the user uses the tab key to

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.