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
colelementcolumn, retrieve code havingid = "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
Post a Comment