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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:46:05+00:00 2026-06-16T00:46:05+00:00

I am writing a jQuery function for an image gallery with thumbnails. There is

  • 0

I am writing a jQuery function for an image gallery with thumbnails. There is a div at the top of the webpage that will display a larger version of a clicked thumbnail as well as a title and a description.

When the thumbnails are clicked, the title changes as I expect but the description remains the default (defined by HTML).

The thumbnails are in an unordered list like so:

<ul class=thumblist id=thumblist>
<li><a title="thumb1" description="this is the first pic"></a></li>
<li><a title="thumb2" description="this is the second pic"></a></li>
</ul>

Here is the jQuery function:

  $('.thumblist a').click(function() {
    $("#title").text(this.title);
    $("#description").text(this.description);         
  }); 

What can I do to fix my markup and achieve the functionality I am looking for?

  • 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-16T00:46:06+00:00Added an answer on June 16, 2026 at 12:46 am

    You want the attr function:

    $('.thumblist a').click(function() {
      var $this = $(this);
      $("#title").text($this.attr("title")); // Or `this.title`, see below
      $("#description").text($this.attr("description"));         
    }); 
    

    The reason it sort of half-worked is that title is a valid HTML attribute that has a reflected property on the DOM element instance, so this.title gave you that attribute; but description is not, so there’s no reflected description property. Using attr goes and looks for the actual attribute value.

    Ideally, use data-* attributes for ad-hoc attributes (like your description) not defined by any standard.

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

Sidebar

Related Questions

Ive been writing a simple jquery function that turns a div with a list
So I am writing some jquery that is basically meant to resize any image
I'm writing a jQuery function where I'd like to access both the native size
I'm writing a jQuery plugin , which similar to this, $(this).each(function(){ $el = $(this).find('.el')
I've been writing some jQuery functions that have JavaScript variables and looping, etc inside
I am writing a jQuery plugin to simulate an editable div. Here is my
I am writing a function that well keep the user in lightbox images while
I have an app that processes images and use jQuery to display progress to
I am writing my first custom function/addon for jQuery, it's been a lot of
I'm having some trouble writing a function to change a background image on a

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.