jquery - Using Javascript replace on a element -



jquery - Using Javascript replace on a <td> element -

i have done quite bit of searching on site (and web) in relation query cannot straight answer. need remove word "other" dynamically created table. code using follows:

<td id="testclass">other option</td>

class="snippet-code-js lang-js prettyprint-override">var str = document.getelementbyid('test').innerhtml; var text = str.replace("other", ""); document.getelementbyid("test").innerhtml = text; class="snippet-code-html lang-html prettyprint-override"><td id="test">other option</td>

for reason though, not work element work p, span, div etc.

can shine lite on this? have tried jquery options , still same thing.

here on jsfiddle

you're missing whole table:

<table> <tr> <td id="test">other option</td> </tr> </table>

to explain : in absence of table <td> omitted html, leaving element's context without it's parent. since td has id gets lost, js in case, on dom ready cannot find specific id.

fiddle

javascript jquery html

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -