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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:25:47+00:00 2026-05-10T19:25:47+00:00

I have ASP.Net code similar to the following (this is inside a FIELDSET): <ol>

  • 0

I have ASP.Net code similar to the following (this is inside a FIELDSET):

<ol>     <li>         <label>Some label</label>         <one or more form controls, ASP.Net controls, labels, etc.>     </li>     <li>         <label>Another label</label>         <... more of the same...>     </li>     ... </ol> 

I’m trying to keep my markup as clean as I possibly can, but I’ve decided that for various reasons, I need to wrap a DIV around everything in the list item after the first label, like this:

<ol>     <li>         <label>Some label</label>         <div class='GroupThese'>            <one or more form controls, ASP.Net controls, labels, etc.>         </div>     </li>     <li>         <label>Another label</label>         <div class='GroupThese'>             <... more of the same...>         </div>     </li>     ... </ol> 

I would rather do this with ‘unobtrusive Javascript’ via jQuery instead of littering my page with extra markup so I can keep the form semantically ‘clean’.

I know how to write a jQuery selector to get to the first label in each list item $(‘li+label’) or use :first-child. I also know how to insert things after the selection.

What I can’t figure out (at least this late at night) is how to find everything after the first label in the list item (or basically everything in the list item except for the first label would be another way to put it) and wrap a DIV around that in the document ready function.

UPDATE:

Owen’s code worked once I removed the single quotes from around:

$('this')

and set the proper decendent selector:

$('li label:first-child')

in order to only select the first label that occurs after a list item.

Here is what I did:

$(document).ready(function() {      $('li label:first-child').each(function() {         $(this).siblings().wrapAll('<div class='GroupThese'></div>');     }); }); 
  • 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. 2026-05-10T19:25:48+00:00Added an answer on May 10, 2026 at 7:25 pm

    edit: corrected code (see old code in revision history and comments for more info)

    ok this should work:

    $('li label:first-child').each(function() {     $(this).siblings().wrapAll('<div class='li-non-label-child-wrapper'>'); }); 

    from:

    <li>     <label>Some label</label>     <div>stuff</div>     <div>other stuff</div> </li> <li>     <label>Another label</label>     <div>stuff3</div> </li> 

    produces:

    <li>     <label>Some label</label>     <div class='li-non-label-child-wrapper'>       <div>stuff</div>       <div>other stuff</div>     </div> </li> <li>     <label>Another label</label>     <div class='li-non-label-child-wrapper'>       <div>stuff3</div>     </div> </li> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET web site with something similar to the following code: .aspx
I have following asp.net code but it gives error when I change dropdown selected
We have some legacy ASP.NET code that detects if a request is secure, and
I have some C# code in my ASP.NET MVC3 project that's throwing an exception
I have two very similar pieces of ASP.NET code that send a file in
I have an ASP.NET MVC view that contains a lot of similar code and
I have one asp.net page. I want to add this page to asp.net mvc
Following on from this question: ASP.NET MVC Routing with Default Controller I have a
I have ASP.Net code generating my button's HTML for me using divs to get
I have asp.net generated html code. I want execute jQuery click function when user

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.