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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:41:58+00:00 2026-05-31T20:41:58+00:00

Struggled to adequately describe the scenario in the question. I’m trying to learn jQuery

  • 0

Struggled to adequately describe the scenario in the question. I’m trying to learn jQuery so there will no doubt be a bundle of mistakes in what I already have.

This is the jQuery code I have thus far.

$(document).ready(function() {
 $('a.x', $('#innerlayout')).hover(
  function () {
   var path = $(this).attr('rel');
   var text = $(this).attr('title');
   $(this).append($("<p class='revealer'><img src='"+path+"' /><br />"+text+"</p>"));
   $('p.revealer').hide().fadeIn(500);
  }, 
  function () {
    $(this).find('p:last').hide();
    $(this).removeClass('x').addClass("revealed");
  }
 );
 $('a.revealed', $('#innerlayout')).hover(
  function() {
   $(this).find('p').show();
  },
  function() {
   $(this).find('p').hide();
  }
 );
});

and the HTML is basically

<a class="x" href="javascript:void(0)" rel="image1.jpg" title="Image">
 <img src="icon.jpg" width="40" height="40" alt="Icon" />
</a>

My previous incarnation of this used remove() to remove the p tag on mouseout and worked okay. I wanted to try and change it so that the content was just hidden, and the class changed so that if mousenter occurred again it would just show the existing content. Instead I find that it still appends the content again and stacks up on each enter/out. Can anyone suggest where I’m going wrong?

  • 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-31T20:41:59+00:00Added an answer on May 31, 2026 at 8:41 pm

    I ended up using this solution which provided the functionality I sought.

    $(document).ready(function() {
     $('a.x', $('#innerlayout')).hover(
      function () {
      if($(this).hasClass('revealed')){
        $(this).find('p.revealer').fadeIn(500);
      }
      else{
       var path = $(this).attr('rel');
       var text = $(this).find('span.y').html();
       $(this).append($("<p class='revealer'><img src='"+path+"'/><br />"+text+"</p>"));
       $(this).find('p.revealer').hide().fadeIn(500);
       }
      }, 
      function () {
        $(this).find('p.revealer').hide();
        $(this).addClass("revealed");
      }
     );
    });
    

    with this HTML

    <a class="x" href="javascript:void(0)" rel="image1.jpg">
     <img src="radio-hover.png" width="15" height="15" alt="Image available icon" />
     <span class="y" style="display:none;">Any follow up content required</span>
    </a>
    

    Originally the title attribute was used to supply the var text but I found I occasionally need to include html in here and so adopted this approach.

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

Sidebar

Related Questions

I struggled to write a more appropriate 'title' to this question - I will
I've struggled with this a good bit this morning; I'm creating what will eventually
I've struggled with this all day, I am trying to get a random number
I struggled asking that question but here it is. I am using source control
I struggled to come up with a good title for this question, so suggestions
Apologies what what is probably a poor title for this question - I struggled
Over the years, I've struggled with this. This year, there might be a solution.
I've always struggled with this decision, and I wanted to know if there are
I've struggled with this problem for months and know there has to be a
Struggled with this for a few hours now so time to ask a question.

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.