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

  • Home
  • SEARCH
  • 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 4346148
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:08:06+00:00 2026-05-21T12:08:06+00:00

I have the following divs: <div class=vote> <input type=hidden name=reply-id value=83743> <a class=vote-up-0 title=Vote

  • 0

I have the following divs:

     <div class="vote">
     <input type="hidden" name="reply-id" value="83743">
     <a class="vote-up-0" title="Vote Up This Comment">up</a>
     <a class="vote-down-0" title="Vote Down This Comment">down</a>
     </div>


     <div class="vote">
     <input type="hidden" name="reply-id" class="reply-id" value="83745">
     <a class="vote-up-0" title="Vote Up This Comment">up</a>
     <a class="vote-down-0" title="Vote Down This Comment">down</a>
     </div>

(Yes, it’s a blatent(ish) copy of SO code, I’m trying to see how they do it).
So when a user clicks either vote up or vote down, it should find the hidden id.

This doesn’t seem to work:

       $('a.vote-up-0').click(function() {

           var id = $(this).closest('.reply-id').val();
  • 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-21T12:08:06+00:00Added an answer on May 21, 2026 at 12:08 pm

    closest works by going up the DOM tree to find the first element that matches a selector. It only matches ancestor elements. At no point does it look at sibling elements.

    You want to use siblings:

    $(this).siblings('.reply-id').val();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of divs in the following structure: <div id=team> <div class=member>
If I have the following: <div class=apple-monkey></div> <div class=apple-horse></div> <div class=cow-apple-brick></div> I can use
Lets say i have the following web page: <html> <body> <div class="transform"> <span>1</span> </div>
I have the following snippet of code: $(#QnAList).append(<div id=qdiv + i + class=divBase> <span
I have the following Javascript/jQuery function: function addEventHandler(){ $(div).mouseenter(function() { $(this).html(Over); }).mouseleave(function() { $(this).html(Out);
i have the following jquery code. basically i will have several overlapped divs and
I have a repeater that outputs divs like the following for every item returned
I have the following bit of code to display thumbnails on a page: <div
I have the following markup, I took the extra stuff out of the divs,
I have the following DIV layout which translates as little clickable buttons on the

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.