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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:44:51+00:00 2026-05-18T02:44:51+00:00

Need a little help with what I’m sure is fairly easy jquery I have

  • 0

Need a little help with what I’m sure is fairly easy jquery

I have the following repeating markup (several list items)

<li>
<div class="answer">
<p><select class="dropdown">
..options..
</select></p>
</div>
<div class="commentBox">
..content..
</div>
</li>

Depending on the value of the selected option when the pages loads, the “commentBox” will be shown/hidden.

I have tried the following jquery

var dd = $('.dropdown');
var com = $('.commentBox');


dd.each(dd, function(n, val){
if($(this).val() == 'whatever'){
   com[n].setStyle('display', 'none');
}
});

I get an error “b.apply is not a function”

So in my head, how it should work – if it’s the first select dropdown, show/hide the first “commentBox” div. If it’s the second dropdown then show/hide the second “commentBox” div. And so on.

I think I have got in a mess trying various jquery techniques so I am sure there are dozens of possibilities here.
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-05-18T02:44:52+00:00Added an answer on May 18, 2026 at 2:44 am

    Your problem is that you’re passing an extra (first) parameter to each.
    each only takes the set as the first parameter when called statically.
    In other words:

    $.each(dd, function() { ... });
    

    or

    dd.each(function() { ... });
    

    Note that you can make your code clearer by changing it to

    $(this).closest('li').find('.commentBox').hide();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need a little help again. Say I have an unordered list, and I want
Need a little help with a SQL / ActiveRecord query. Let's say I have
Need a little help with my jquery here I want all my button with
I need a little help brainstorming on a query. I have a sales table
I need a little help figuring out what the following URL rewrite rule means.
I need little help with inheritance in C++. I have code with same structure
I need little help on following requirement, as I know very little about C
need a little help with this one. I have a form that I am
I need a little help on a problem with navigation controllers. I have a
I need a little help with my new assignment. Problem: Given Two Linked List

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.