我有一块DOM的这样替换所有的字符串中的DOM元素
<table style="display:none;" id="risposta-campione">
<tr>
<td>
<label>Risposta</label><textarea id="risposta_0000" name="risposta_0000" cols="35" rows="2"></textarea>
<button type="button" onclick="cancellaRispostaDomanda('0000')" class="cancella-risposta"></button>
<button type="button" onclick="aggiungiRispostaDomanda('0000')" class="aggiungi-risposta"></button>
</td>
</tr>
</table>
我想要替换所有“0000”的出现与jQuery没有得到每个元素。
这可能吗?
我尝试这样做:
elem = $('#risposta-campione').text() // how convert dom to string?!
elem.replace('0000', 'hello');
无解: -/
太棒了!很棒!非常感谢! :-) 后代,替换全部: $('#risposta-campione tr')。html()。replace(/ 0000/g,'hello'); – Roberto 2011-04-15 15:13:37