jquery - How to wrap elements in a <td> and then append the td to tr -


i have code:

<tr id="row">     <td id="col">         <img>         text         <p></p>     </td> </tr> 

i want take each "text" , <p> tr, wrap them separately in <td> , add them main <tr>.

the final result shoud this:

<tr id="row">     <td id="col"><img></td>     <td class="text-class">text><td>     <td class="p-class"><p></p></td> </tr> 

i tried find each element , wrap in td cannot right.

any suggestion?

work javascript:

  • to retrieve colelement column, retrieve code having id = "col" (see getelementbyid)
  • to read children of type p, following: var p = colelement.getelementsbytagname("p"); (the same applies other types of children - see this link information)

just iterate on collections retrieve in way, , wrap them in <td> tag adding them children of tag (see the appendchild method further information).


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -