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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:24:44+00:00 2026-06-16T23:24:44+00:00

I have two div containers: <!– button1 –> <div class=voted> <span>name</span> <div class=button>Vote</div> </div>

  • 0

I have two div containers:

<!-- button1 -->
<div class="voted">
    <span>name</span>
    <div class="button">Vote</div>
</div>

<!-- button2 -->
<div class="vote">
    <span>name</span>
    <div class="button">Vote</div>
</div>

Then when using jquery:

$('.button').click(function(){
    // if button2 was clicked:
    var test = $(this).parent().attr("class"); // How do I obtain the other element?
    alert(test); // this should be outputted "voted"
});

I would like to use something like $(this) with some function to get the other element. How would I obtain “voted”? The reason I’m doing this is because I have a script where it will change between two buttons, so when user clicks on button1, I would like them to get class of button2, vice versa.

EDIT

So I have two buttons (to compare two people), initially, they’re supposed to have the same class vote. But I have jQuery codes that when a user clicks on a button, the class changes to voted. Now, I would like to check so that when a user clicks on the OTHER button (to try to vote for the second person), they can’t because there’s already a voted class, or they already pressed the first button.

I know that I can just check my whole page if voted exists, but I have set up some check when user clicks on their initial voted person that they voted for, they can take back the vote (which will change the div class back to vote).

My whole premise is: not to allow user vote the other person if user already voted for someone.

Sorry for the long description.

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-16T23:24:45+00:00Added an answer on June 16, 2026 at 11:24 pm

    I solved what I’m trying to do

    var voted = $(".voted").not($(this).parents(".voted")).attr("class");
    

    This allows me to check if class voted exists, but it doesn’t check if $(this) one that was pressed exists.

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

Sidebar

Related Questions

I have a bunch of thumbnail containers with a class and then two containers
I have two div containers with content in them and two buttons outside the
For example I have two div containers like the one below: ^^^^^^^^^^^^^^^^^^<br/> DIV 1
I have two nested containers, .button-1x1 and the inner .button-content. I want to express
I have built two control containers on a page, one is using jquery-ui tabs
I have two div containers that are sortable and connected with connectWith . In
Is there a way to have two <div> containers, one having a static height,
I have an ASP.NET page that contains two div's. Both have search fields and
I have these div blocks called columns where each column div contains separate two
I have a div that contains two other divs,, like this: ---------------------------- | |

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.