1

I'm trying to remove the id from all <td> that are named "date[]", because if i keep the id, a jquery datepicker messes up later.

the following function is used to remove the id

document.getElementsByName('date[]').removeAttribute('id');

Firebug tells me: TypeError: document.getElementsByName(...).removeAttribute is not a function

I tried all combinations of ' and ", and also just date instead of date[]. I don't think its a typo, because i copied this from w3schools

1
  • 1
    does document.getElementsByName('date[]') return a collection of DOM nodes? Commented Jan 22, 2015 at 19:16

1 Answer 1

4

document.getElementsByName returns a collection, you have to iterate and remove:

var collection = document.getElementsByName('date[]'); for (var i = 0; i < collection.length; i++) { collection[i].removeAttribute('id'); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.