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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:15:02+00:00 2026-05-24T11:15:02+00:00

I have created a function called billingOptions() it is associated with a dropdown (select)

  • 0

I have created a function called billingOptions() it is associated with a dropdown (select) element. When a user selects an option in the dropdown the function is run.

The dropdown will dynamically be added through the page…each time adding the billingOptions() function onChange. I am trying to use Jquery to find the closest instance of the class=rate from the dropdown that was changed. Keep in mind that the dropdowns are added dynamically so there could possible be many instances of .rate…

I have tried using “this” and “closest” to find the nearest class (i’m not even sure you can use a class with the closest function). Here is some code:

***I was asked to provide the exact structure of the HTML (the rows of the table are dynamically generated. The table is static).

<table id="billTasks"> 
<tr> <input class="taskNameInput" type="text" size="52" placeholder="Task Name" name="task:1" disabled="disabled"> <select class="billOptions" onchange="billingOptions(this)">
<option class="fixedRate">Bill Fixed Rate</option>
<option class="hourly">Bill Hourly</option>
</select> 
<input type="text" name="fixedRate" placeholder="Rate" class="fieldWidth100 rate"/> 
</tr> 
</table>

function billingOptions(){
 $(this).closest('.rate').hide();
}

***EDIT: this code does not work. The goal is to hide the input.rate element.

  • 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-24T11:15:03+00:00Added an answer on May 24, 2026 at 11:15 am

    Edit: First off, you are half-right about your concern that this is not being passed to the function. It is being passed, but it is not being used. Give your function a named parameter, and reference that instead of this:

    function billingOptions(el)
    {
        $(el).something()...
    }
    

    Is .rate always the next element? If so:

    $(el).next(".rate").hide();
    

    Is .rate always a sibling? Will there only ever be one .rate sibling? If so:

    $(el).siblings(".rate").hide();
    

    Will .rate share a common parent with your select, and be the only instance of .rate in that common parent? If so:

    $(el).closest(".commonParentClassName").find(".rate").hide();
    

    If none of these works for you, please provide more detail on the structure of you HTML.

    Edit: Thanks for posting the structure of your HTML. You are missing <td> in your HTML. Assuming your real code includes the <td>, and assuming there is only one .rate per row, try this:

    function billingOptions(el)
    {
        $(el).closest("tr").find(".rate").hide();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a StartComObjects function called when the user presses the Login button and
I have created a custom view by extending AutoCompleteTextView (with a specialized function called
I have created an AJAX function that when called it changes the color of
I have three classes that all have a static function called 'create'. I would
I have created a function that takes a SQL command and produces output that
I have created a function outside of $(document).ready() , but am still using jQuery
I have created a function in PHP that calls a webservice and parses through
in my data layer class I have created a function to manually refresh the
Hey, so I have created a function to check the DB for unique entries,
I have created a JS function which executes fine when it's included an the

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.