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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:13:38+00:00 2026-06-02T12:13:38+00:00

Hi everyone , Actually, i got c.replace is not a function while i was

  • 0

Hi everyone,

Actually, i got “c.replace is not a function” while i was trying to delete some DOM elements and..i don’t understand.

i’d like to delete some

  • tags from the DOM and so, i did it :

    var liste=document.getElementById("tabs").getElementsByTagName("li");
    
        for(i=0;i<liste.length;i++)
        {
            if(liste[i].id==2)
            {
                $("#tabs").detach(liste[i]);
            }
        }
    

    I tried .detach and .remove but it’s the same. My version of jQuery is 1.7.1.min.js.

    Thanks for help.

    • 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-02T12:13:42+00:00Added an answer on June 2, 2026 at 12:13 pm

      order of iteration on a NodeLIst

      Doing forward iteration of a NodeList that is being modified when you remove an element can be an issue. Iterate in reverse when removing elements from the DOM.


      misuse of detach()

      Also, the arguments to .detach() do not perform a nested find, but rather act as a filter on the existing element(s) in the jQuery object, and should be passed a string. It seems that you actually want to detach the li, which would mean that you’d need to call .detach() on the li itself…

      var liste=document.getElementById("tabs").getElementsByTagName("li");
      
      var i = liste.length
      
      while(i--) {
          if(liste[i].id==2) {
              $(liste[i]).detach();
          }
      }
      

      remove() may be preferred

      Keep in mind that if you use .detach(), any jQuery data is retained. If you have no further use for the element, you should be using .remove() instead.

      // ...
          $(liste[i]).remove(); // clean up all data
      

      code reduction

      Finally, since you’re using jQuery, you could just do all this in the selector…

      $('#tabs li[id=2]').remove(); // or .detach() if needed
      

      valid id attributes

      Keep these items in mind with respect to IDs…

      • It’s invalid to have duplicate IDs on a page
      • It’s invalid in HTML4 to have an ID that starts with a number

      In the selector above, I used the attribute-equals filter, so it’ll work, but you should really be using valid HTML to avoid problems elsewhere.

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

    Sidebar

    Related Questions

    hi everyone ive got quite an error here it seems like c++ is not
    Ive got some data (not that the data actually exists until after I solved
    hi everyone i am new to iphone development. Actually i am trying with some
    Hello Everyone I would like to open a rich:popupPanel inside a conditional expression, actually
    everyone, I have some question about C++, what do You actually prefer to use
    hello everyone I'm trying to understand how 2-3 trees work, I understood a concept
    Hello everyone I got trapped when Im using jquery loading some content into my
    everyone. Please see example below. I'd like to supply a string to 'schedule_action' method
    everyone! new to here and been pondering about this myself for some times with
    everyone. I have some labels that I draw them in the xib file, and

    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.