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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:08:38+00:00 2026-06-07T01:08:38+00:00

I basically have multiple divs that contain information for different words (word, definition, ect.)

  • 0

I basically have multiple divs that contain information for different words (word, definition, ect.) all on one page. So each “word card” is written as the following (I took out some of the extra stuff):

<div id="card">
    <div class="card-info-box" id="definition" wordID="1">To lessen or get rid of any pain or suffering.</div>
    <a href="#" class="definition" wordID="1">Define</a> 
</div> 

I added a custom attribute of “wordID” to each word. I am trying to use jQuery to create a “Define” link that toggles the appropriate #definition div. So far, I have the following jQuery code:

    $(document).ready(function() {
    $('#definition').hide();
    $(".definition").click(function(evt) {
        var d = $(this).attr("wordID");
        $("#definition[wordID=" + d + "], #definition[wordID=" + d + "]").toggle();
    }); 
});

Now with just one one card on a page, the jQuery works fine with toggling it’s respective definition div. However, if I duplicate the card div and change the wordID to 2 on the second set, the second div’s definition link does not do anything. The first one still works as it’s supposed to.

Is there something I need to change so that the jQuery works correctly for each wordID attribute value?

Thanks!

  • 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-07T01:08:39+00:00Added an answer on June 7, 2026 at 1:08 am

    Try below. You don’t need use attribute selector, you could use $(this).siblings('.card-info-box') to select the div you want to toggle.

    $(".definition").click(function(evt) {
        evt.preventDefault();
        $(this).siblings('.card-info-box').toggle();
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Posix Message Queues on Linux. Basically, I have multiple threads that receive
I have a report that is basically a form with multiple empty fields and
Basically: Can my model classes contain @NoBinding annotations with multiple values? If I have
I basically have a program that filters records from one excel file to another
I have multiple divs in a page whose content gets loaded via ajax. I
I have a page that has multiple sliders (from http://www.switchonthecode.com/tutorials/using-jquery-slider-to-scroll-a-div ) and since each
I have multiple Select statements on my page and the options are all the
I have a small usercontrol that basically increments or decrements a value by one.
We have multiple tables that contain static key/value pairs, which are currently pulled using
I have multiple tabs that have different data inside. The first tab has ListView

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.