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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:18:50+00:00 2026-05-28T08:18:50+00:00

I earlier asked another question here However, I later realized that my requirements are

  • 0

I earlier asked another question here
However, I later realized that my requirements are a little different. The above referenced solution takes me only to the error div but I need to scroll up slightly above that to the label for the input text field. Below is the html.

<label class="label_required" for="phone_num_key"></label>
 <table class="table_Box">
  <tbody>
    <tr id="someId" class="redAlert">

       <Some more mark up here>

    </tr>
  </tbody>
 </table>

How can I scroll up to the label instead of the tr element with class ‘redAlert’
I tried the below but it didn’t work for me.

var errorDiv= $('.redAlert:visible').first();
var errorLabel = errorDiv.parent("table").prev("label");
// also tried this
//var errorLabel = errorDiv.closest("label").prev();
var scrollPosition = (errorLabel.offset().top); 
    $(window).scrollTop(scrollPosition);

Looks like the .offeset() function cannot be called on Labels ?

Edit – Please note that there are multiple such labels on the form so I cannot basically use the class selector

  • 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-28T08:18:51+00:00Added an answer on May 28, 2026 at 8:18 am

    offset() does work. problem is parent().

    use errorDiv.parents('table').prev('label');

    FYI,

    .parent( [selector] )

    Given a jQuery object that represents a set of DOM elements, the
    .parent() method allows us to search through the parents of these
    elements in the DOM tree and construct a new jQuery object from the
    matching elements. The .parents() and .parent() methods are similar,
    except that the latter only travels a single level up the DOM tree.

                                               from http://api.jquery.com/parent/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see that the above question was asked earlier, however even after referring them
I asked a question here earlier today and got that fixed, but now I
I asked another version of this question on the gamedev.SE site earlier today but
I asked this question earlier. I am intrigued by std::set but I have another
Related to a question I asked earlier here , I've found a problem which
I'm re-casting a question I asked earlier now that I have an idea of
Alright. So I asked a question here but I feared that I anwsered it
I know I asked a related question earlier. I just had another thought. using
This is a follow-up to another question I asked earlier today. I am creating
i had asked earlier about the same kind of question but that was in

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.