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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:35:06+00:00 2026-05-20T10:35:06+00:00

I have a DIV block with 3 DIV elements: upvote, votes, and downvote. When

  • 0

I have a DIV block with 3 DIV elements: upvote, votes, and downvote. When I click on upvote or downvote and call parent.html(html) within a JQuery block of code it overlays the vote count over the upvote or downvote icon. Which JQuery call would I use to gain access to the DIV class, “votes”? Would I find the parent of the parent element and then search for the “votes” class? Are there any ways to find an element’s siblings by name? Sorry for the newbie question but I am still very new to JQuery!

  • 1 1 Answer
  • 1 View
  • 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-20T10:35:06+00:00Added an answer on May 20, 2026 at 10:35 am

    Assuming your mark-up is approximately:

    <div>
        <div class="upvote">vote up</div>
        <div class="votes">0</div>
        <div class="downvote">vote down</div>
    </div>
    

    You could use either:

    $('.upvote').siblings('.votes');
    

    Or:

    $('.upvote').parent().find('.votes');
    

    References:

    1. siblings(): JS Fiddle,
    2. parent(),
    3. find().

    Edited in response to question from OP (in comments):

    Ohhhh no it’s not a problem with there being more than one sibling ‘.votes’ div. The problem is that there are more than one submissions on a given page and when you upvote one the rest get upvoted as well. I think this is why I need to use $this or something to only use the selected submission. Any ideas?

    I’m not sure what, exactly, you mean by ‘more than one submissions on a given page,’ but I’m assuming you mean, simply, that there are multiple voting elements on the page. If that’s the case (and I’m assuming the mark-up is consistently as I approximated in the first part of this answer), you can use:

    $('.upvote').click(
        function(){
            $(this).siblings('.votes');
            // this is just a selector, it won't 'do' anything
            // other than select the element.
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following HTML: <div class=olympics style=display: block; position: absolute; left: 250px; top: px;>
I have this html <div id=cont> <div id=videowrapper class=fitmein> <div id=vimeoposition style=display: block;> <div
I have a block-level HTML element that contains multiple block-level and inline-level elements, e.g.
I a template, I have five DIV elements underneath each other on a HTML
I have the following code: $('body').mousemove(function() { $('#covering').fadeOut(500); $('.block div div').fadeOut(250) $('.block div div').css('margin-top','160px')
I have HTML markup like this: <div id=blocks> <div class=block></div> <div class=block></div> <div class=block></div>
I have a div with a link and on click should open a jQuery
I have 2 div elements side by side that are set as inline-block. They
I have two DIV elements. HTML looks like this: <div id=first><div id=second></div></div> The CSS
I have some code like: <div>First</div> <div class=second>Second</div> <a>Alink</a> div{ display: block; float:left; }

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.