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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:28:24+00:00 2026-06-15T20:28:24+00:00

I am writing a function to update an order receipt every time the user

  • 0

I am writing a function to update an order receipt every time the user updates and then closes a product pop-up overlay.
The function searches each input of the form, and then adds the info to the receipt div if its value is greater than 0. I am trying to get the .html() of the label element situated above the input field and which describes the current item, and to use this as the description of the item in the receipt.

I have tried using without success:

 - $this.closest('label').html() 
 - $this.prev('label').html()
 - $this.find('label').html()
 - this.element.find('label').html()

Here is my code. The section I am talking about is the ‘label is’ part…

function updateOrder(){

var items = '';
$('input').each(function(){
    var $this = $(this),
        i_value = $this.attr('value');

    if(i_value > 0){
      items += $this.attr('id') + ' Quantity: ' + i_value + '<br/>' 
      + 'label is: ' + $this.closest('label').html() + '<br/>';  
    }
});

$('#d_reciept').html(items);

}

and a sample form item

<tr>
<td class="td_thumbs">
    <div>
        <a class="fancybox" data-fancybox-group="vinyl-banners" href="img/products/vinyl-corporateblue.jpg"> <img src="img/products/thumbs/vinyl-corporateblue-thumb.png" alt="vinyl c-blue"/></a>
        <label>Corporate Blue</label>
    </div>
</td>
<td>6</td>
<td>
    <input id="vinyl-blue" type="number" max="6" min="0" value="0"/>
</td>
</tr>
  • 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-15T20:28:25+00:00Added an answer on June 15, 2026 at 8:28 pm

    The function closest give you first accurance of given selector in ancestors, your label is not in the first ancestors, rather in the parent tr children, You need to go to parent tr and then use find to search its parent for label.

    $(this).closest('tr').find('label').html()
    

    or

    $(this).closest('tr :td:eq(0)').find('label').html()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a function to update my XML and am having some issues.
I am writing Classic ASP program.In one function, I have to use 2 update
I am writing a function for a program that asks the user to input
I am writing function that involve other function from base R with a lot
I'm currently writing a function what would create a zip file, which will be
I'm writing a function, which determine the number of useful bits of a 16
I'm writing a function which will drop a table if it already exists. It
I am writing a function in Haskell that deals with numbers beyond the length
I am writing a function short getBits(short data, int p, int n) I have
I'm writing a function that replaces long hex coded color ( #334455 ) with

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.