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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:05:01+00:00 2026-05-19T12:05:01+00:00

Such as the div container: <div class=container> <ul> <li id=apple> apple </li> <li id=banana>

  • 0

Such as the div container:

<div class="container">
  <ul>
    <li id="apple"> apple </li>
    <li id="banana"> banana </li>
    ....
  </ul>
</div>

And I am going to append new more li elements inside the container,so I need a way to check if that li’s id which will append had been used or not?

[update]

In my case I would have several containers , So, the li elements which will have the same id possibly inside one or more of them in the same time.

Thank you very much!?

  • 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-19T12:05:02+00:00Added an answer on May 19, 2026 at 12:05 pm

    You can only have one unique id per page. So you should never have two or more list items with the same id even if they might be in different containers. You would want to change class=”container” to id=”container” and append the li to just that one div. OR you need to change your list item id=’orange’ to class=’orange’ then you could add that list item to every div with a class of container. I assume the second choice is what you want to do.

    newlistItem = "<li class="orange"> orange </li>"; //build the new list Item
    
    var newId = $('newlistItem').attr('class'); // load the class of the li you want to append
    
    var findId = "." + newId; //build the selector you want to find
    
    foundListItem = $('.container').find(findId);
    
     if (foundListItem.length == 0) {  // if not found we can now add it
    
      // this will add li to every div with class container (use an id for just one div)
      $('newlistItem').appendTo('.container'); 
    
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<div id=container> <div class=active> <div class=active></div> </div> <div> </div> </div> How to write such
I would like to create such Div structure --------div-container------- ----------div-menu---------- --div-title--|--div-submenu- <div class=div-container> <div
So I have 3 divs contained inside a containing div like such: <div id=contain>
I have such div: <div class=box> <div id=myid style=display:hidden;> <p>some stuff here</p></div> </div> when
I want to postion a DIV inside a page such that it is visible
A regular dom element is such as: document.getElementById('a') or document.createElement('div') But jQuery returns elements
I am generating menu with such tags: <div class=animatedtabs> <ul> {% for item in
i use such code, but it renders with error <li class=dd0><div id=dt1<a href=http://localhost:1675/Category/29-books.aspx>Books</a></div></li> there
so I have my main layout as such: <div class=menu> <?php include('/menu.php'); ?> </div>
I have an example DOM as such below where new child elements can be

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.