Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question removing elements from an objectHTMLCollection

    I have an array of input objects, and need to remove some depending on the value of their attributes. When I try inputArray.splice(), however, I am told that that is not a function. How do I remove elements from an objectHTMLCollection?

    *MUST work in IE; FF would be nice too (but not necessary)

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    HTMLCollection.prototype.splice = Array.prototype.splice

    Might actually make it work in Firefox. More generally, however, say:

    var collection = [object HTMLCollection] // reference to your collection

    // delete the 6th element
    collection[5].parentNode.removeChild(collection[5]);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •