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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:09:42+00:00 2026-05-31T01:09:42+00:00

Ok – so I’ve made a little image gallery – basically when you click

  • 0

Ok – so I’ve made a little image gallery – basically when you click a thumbnail, it pulls in the title from the alt tag – puts it in a div to display below the image as the title, and displays the image as a fullscreen bg

What I’m trying to do is have this title display when the page loads – and when you click, remove the existing value and replace it with the new one

Currently the title isn’t displaying on page load, when you click it – it shows the title as desired, but when you click another image it doesn’t remove this title

Heres my existing code

    <ul id="horses">
                <li><a class="clicker" rel="drawings-bg"><img src="/assets/img/portfolio/horse.jpg" alt="horse" /></a></li>
                <li><a class="clicker" rel="contact-bg"><img src="/assets/img/portfolio/dogs.jpg" alt="dogs" /></a></li>
                <li><a class="clicker" rel="drawings-bg"><img src="/assets/img/portfolio/horse.jpg" alt="horse" /></a></li>
    </ul>

Jquery

     $(document).ready(function() {
    var imginfo = $('.imgtitle');
$("ul#horses li img").click(function() {
      if(imginfo)  $(imginfo).siblings('.imgtitle').remove();
$(this).parent().append("<div class=imgtitle>" + $(this).attr("alt") + "</div>");
     });
});

Thanks in advance

  • 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-31T01:09:43+00:00Added an answer on May 31, 2026 at 1:09 am

    Most of it seems to work:

    This line has a problem:

    if(imginfo)  $(imginfo).siblings('.imgtitle').remove();
    

    jQuery instances are always truthy, so that line will always run. Ignoring that, though, shouldn’t it be more like this?

    $(document).ready(function() {
      var imginfo = $('.imgtitle');
      $("ul#horses li img").click(function() {
        $('ul#horses li .imgtitle').remove();
        $(this).parent().append(
          "<div class=imgtitle>" + $(this).attr("alt") + "</div>"
        );
      });
    });
    

    …if you’re trying to remove the other titles when displaying a new one: http://jsbin.com/iqugih

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

Sidebar

Related Questions

My NSXMLParser breaks on this string: <title>AAA &#8211; BCDEFGQWERTYUIO</title> I parsed it in this
I am currently running into a problem where an element is coming back from
An extension to my previous question: Text cleaning and replacement: delete \n from a
I am getting the value from web service like &gt;&lt;&amp;&nbsp; etc. I want to
I am currently scraping some data from the internet and converting into xml documents.
The problem with unsigned char. I am reading a PPM image file which has
I would like to count the length of a string with PHP. The string
I've got the following login script.. <?php $name = $_POST[name]; $password = $_POST[password]; $query
So to start, I have an array of XML files. These files need to
I'm struggling to position the second level of a dropdown nav menu and 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.