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

The Archive Base Latest Questions

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

i have: <ul class=rating> <h3>Like this</h3> <li class=rating-number> <div id=iLikeThis class=iLikeThis> <span class=counter>2</span> </div>

  • 0

i have:

<ul class="rating">
    <h3>Like this</h3>
    <li class="rating-number">
        <div id="iLikeThis" class="iLikeThis">
            <span class="counter">2</span>
        </div>
    </li>
</ul>

this is my jquery code

$('.iLikeThis .counter').each(function() {
        $(this).parent().parent().parent().children('h3').text('You like this');
        $(this).parent().addClass('like');
});

Is there a better way to select the nearest h3 element. It does work with 3-times parent() but not with closest(‘h3).

Why?

  • 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-20T03:44:35+00:00Added an answer on May 20, 2026 at 3:44 am

    As h3 is not a parent of .counter, that won’t work. Use .closest() on .rating instead and find its h3:

    $(this).closest('.rating').children('h3').text('You like this');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model, Rating , which looks something like this: class Rating(models.Model): upvotes
I have a model set out like so: class Rating # user_id, author_id end
i have code like this. which is actually a form .which lets user updates
I have an object now: class Items attr_accessor :item_id, :name, :description, :rating def initialize(options
I have li elements <ul class=> <li class=current-rating id=current-rating style=width: 0px></li> <li><a href=# title=1
My Grails application has a large number of enums that look like this: public
I have a class like so: class Item attr_accessor :item_id, :name, :address, :description, :facilities,
I have a question my db model looks like: class UserAnswer (db.Model): user =
I would like to get returned value from my webservice. I have my class
For the following code: <% foreach (Entities.Core.Location loc in locations){ %> <div class=place_meta> <img

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.