0
我有一个html寺庙,它的字段名称以'SAMPLE'开头。使用jQuery我需要获取完整的html内容并从中删除所有SAMPLE文本,并将更新后的html内容添加到另一个div。这是我的代码。示例代码在这里:http://jsfiddle.net/m4fLb85L/jQuery替换()不适用于整个html内容
<div class="sample_data" style="display:none;">
<div style="float:left; margin-right:5px; width:75px;" class="sizes_element">
<div style="text-align:center;">
<select class="size-selector" listkey="2" name="SAMPLEsize2[38]">
<option value="22">X</option>
<option value="23">L</option>
<option value="24">M</option>
</select>
</div>
<div><input class="SAMPLEsquantity" style="text-align:center;" type="text" name="SAMPLEqty2[38]" value="0"></div>
<div><input class="SAMPLEsprice" style="text-align:center;" type="text" name="SAMPLEprice2[38]" value="0.00"></div>
<div><input class="SAMPLEsofferprice" style="text-align:center;" type="text" name="SAMPLEofferprice2[38]" value="0.00"></div>
<div style="text-align:center;"><input class="SAMPLEsdefault" type="checkbox" name="SAMPLEdefault2[38]"></div>
</div>
</div>
<div id="output"></div>
jQuery的一部分
$(document).ready(function(){
var sData = $('.sample_data').html().replace('SAMPLE','');
$('#output').html(sData);
});
我的问题是示范文本被删除只有第一个元素。但我需要从整个html内容中删除。我怎样才能解决这个问题。
谢谢Milind – RajivRisi 2014-09-05 07:49:53
@RajivRisi:很高兴它帮助:) – 2014-09-05 07:53:01