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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:31:14+00:00 2026-06-17T04:31:14+00:00

I have the current code: <div class=submenu id=submenu0> <ul class=root id=root0> <li class=line_element line0><a><img

  • 0

I have the current code:

<div class="submenu" id="submenu0">
    <ul class="root" id="root0">
        <li class="line_element line0"><a><img src="images/lifevl13.jpg" style="padding-left: 5px; width:20px; height:20px;" />Video</a></li>
        <li class="line_element line0" id="line_element0"><a><img src="images/lifevl12.jpg" style="padding-left: 5px; width:20px; height:20px;" />Ebook</a></li>
        <li class="line_element line0" id="line_element0"><a><img src="images/lifevl3.jpg" style="padding-left: 5px; width:20px; height:20px;" />Music/Audio</a></li>
        <li class="line_element line0" id="line_element0"><a><img src="images/lifevl2.jpg" style="padding-left: 5px; width:20px; height:20px;" />Email</a></li>
        <li class="line_element line0" id="line_element0"><a><img src="images/lifevl4.jpg" style="padding-left: 5px; width:20px; height:20px;" />Mail</a></li>
    </ul>
</div>

I dynamically clone the above and place it in another part of the page which is also dynamically created. What I want is for the line0 part to change to line1, line2 etc. as new elements are added, that way I can track them.

My add button event handler typically performs this action, but for some reason I can’t seem to get it to work on each individual ‘li’ element. I would post my jquery, but it’s a whole lot of code so unless you request it I won’t provide it here.

Edit: (Ok here’s parts of the jquery)

    var numOfParts = ($('.gig_parts').length);
    $('.root.line_element:last').attr('id', 'line_element'+numOfParts);

The ‘numOfParts’ variable keeps track of the ‘fieldsets’ which are dynamically created and tacks it onto the end of my id’s, I understand this isn’t a good way of doing this, but trust me, I’m too far into change it now, perhaps in a later redesign. I’m still rather new to all this.

  • 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-17T04:31:16+00:00Added an answer on June 17, 2026 at 4:31 am

    My approach to a similar situation has historically been to eschew clone and to create the elements from scratch each time, either (1) with jQuery or (2) with a document fragment. That way, you can control the id and class with less fuss.

    As it says in the jQuery documentation:

    Note: Using .clone() has the side-effect of producing elements with
    duplicate id attributes, which are supposed to be unique. Where
    possible, it is recommended to avoid cloning elements with this
    attribute or using class attributes as identifiers instead.

    That said, you may like to look at this post for some further commentary. This and this may also be of interest.

    Further thoughts:

    Regarding incremental class and id numbers, the key issue is the purpose they are serving. If you can avoid giving each element a unique id and deal with it effectively in another manner, then that’s preferable. The same can be said for each class. Javascript and jQuery allow you to deal with this element, and so it may be that you don’t need unique identifiers at all.

    In my case, I build thousands of elements by AJAX from a database, and each one has a unique id that corresponds to its database index. This is necessary to maintain the link between the HTML element and the MySQL record, but that may not be the case in your situation. It’s certainly not the same as building an index from 1 every time.

    In summary, you need to establish what the unique class and id identifiers are achieving for you 🙂

    • 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 code: <div id=filter-bar> <ul> <li><a href=#image class=current><?php _e('Image','sofa'); ?></a></li>
I have the following code that creates a submenu based on current document. The
I have this code, and I want on click on div with favoriteButton class,
I have this code: <div class=window-compl> <div class=window showincatalog showing> <h2>Text1</h2> </div> <div class=window>
As a beginner in Ocaml, I have this current working code: ... let ch_in
The code i current have is this. function update (){ latest_id = $('#image:first').data('position'); /*
I have my current google maps code working to the point where if I
I am having a bit of difficulty with this current code I have set
I have some code that gets the current logged in user. userID = request.session.get(_auth_user_id)
I have following code return (EseshEntities.Current.Users.Select(u => new { Comunity = u.Apartment.Building.District.City })).ToList(); if

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.