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

  • Home
  • SEARCH
  • 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 8849199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:35:20+00:00 2026-06-14T12:35:20+00:00

following is the HTML <div id=serverList class=content> <div class=boxtitle> </div> <div id=’serverInfo1′ class=formEl_b> <fieldset>

  • 0

following is the HTML

<div id="serverList" class="content">
    <div class="boxtitle">
    </div>
    <div id='serverInfo1' class="formEl_b">
        <fieldset>
            <legend>Server #1</legend>
            <div class="section">
                <label>
                    Server Description<small>Linux</small></label>
                <div>
                    <input type="text" id="serverDescription" class="serverDescription medium" /><span class="f_help"></span></div>
            </div>
            <div class="section">
                <label>
                    Server HostName<small>SRV_FR_TERT</small></label>
                <div>
                    <input type="text" id="serverHostName" class="serverHostName medium" /><span class="f_help"></span></div>
            </div>
        </fieldset>
    </div>
    <div id='serverInfo2' class="formEl_b">
        <fieldset>
            <legend>Server #2</legend>
            <div class="section">
                <label>
                    Server Description<small>Windows 2003</small></label>
                <div>
                    <input type="text" id="serverDescription" class="serverDescription medium" /><span class="f_help"></span></div>
            </div>
            <div class="section">
                <label>
                    Server HostName<small>SRV_EQ_SFGT</small></label>
                <div>
                    <input type="text" id="serverHostName" class="serverHostName medium" /><span class="f_help"></span></div>
            </div>
        </fieldset>
    </div>
    <div id='serverInfo3' class="formEl_b">
        <fieldset>
            <legend>Server #3</legend>
            <div class="section">
                <label>
                    Server Description<small>iOS</small></label>
                <div>
                    <input type="text" id="serverDescription" class="serverDescription medium" /><span class="f_help"></span></div>
            </div>
            <div class="section">
                <label>
                    Server HostName<small>SRV_WR_RQRT</small></label>
                <div>
                    <input type="text" id="serverHostName" class="serverHostName medium" /><span class="f_help"></span></div>
            </div>
        </fieldset>
    </div>
</div>

I am trying to iterate the above html using JQuery and to print description and hostname for every server

$("#serverList").children(".formEl_b").each(function () {

      // this is what i am trying to get with no success:
      var description = $(".formEl_b .serverDescription").val();
      var hostname = $(".formEl_b .serverHostName").val();

      alert(description);
      alert(hostname);

});

The problem that i’m having is that it always prints the first description and hostname even that there are 3 items of that kind.

  • 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-14T12:35:22+00:00Added an answer on June 14, 2026 at 12:35 pm

    Your selector

    $(".formEl_b .serverDescription")
    

    Is finding all elements with the class .serverDescription that appear anywhere in the DOM as a descendant of .formEl_b, but since you are already looping the parent elements you can use something like this :

    $("#serverList").children(".formEl_b").each(function () {
          var description = $(this).find(".serverDescription").val();
          var hostname = $(this).find(".serverHostName").val();
          alert(description);
          alert(hostname);
    });
    

    Replaces your selectors with find() to just search the descendants of the current element within the each loop

    find() is marginally faster than using a selector with context (ie $(".serverDescription", this))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html <div class=section> <div>header</div> <div> contents <div>sub contents 1</div> <div>sub
I have the following html : <div class=backpack_all> //wrapper for all on screen content
I have the following HTML: <div id=Content> <div class=MyDiv>...</div> <div class=MyDiv>...</div> </div> The MyDiv
I have the following html : <div class=mainmenu> <ul class=blue> <li class=><a href=tst/ id=a1_up><span
Consider the following: HTML <div class=info_bubble> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
I have the following HTML <div class=myclass value=1> <div> <div class=myclass value=> <a class=popup
Given the following HTML: <div class=foo>howdy howdy howdy how</div> <div class=bar>Hello</div>​ and the following
I have the following html <div class=someClass> Some text </div> <div class=someClass> Some other
I have following HTML: <div class=olympics style=display: block; position: absolute; left: 250px; top: px;>
I got the following Html: <div class=horizontalRadio> <label for=SearchBag.DisplayTypeChips id=DisplayTypeChipsLabel> <%=ViewData.Model.T9nProvider.TranslateById(CommonWeb.Chips)%> </label> <%=Html.RadioButton(displayType, DisplayTypes.Chip,

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.