insertRow and id tag

  • Thread starter Christopher Berg
  • Start date
C

Christopher Berg

hi.
is there a way to add an id='...' tag to a table row when using
the javascript insertRow() ?

i wish to be able to manipulate this row later if i need to
using that identifier (eg to toggle its display style).

thank you.
 
R

RobG

Christopher said:
hi.
is there a way to add an id='...' tag to a table row when using
the javascript insertRow() ?

You mean add an id attribute? Yes, insertRow returns a reference to the
newly created row:

<URL: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-39872903 >

var newRow = tableSection.insertRow(-1);
newRow.id = 'someUniqueID';

i wish to be able to manipulate this row later if i need to
using that identifier (eg to toggle its display style).

That seems to indicate that you will use getElementById. Consider
other methods, say keeping references to rows in an object or array, or
use an intrinsic event - they may be more robust and faster.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top