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
Post a Comment