日期:2014-05-16 浏览次数:20429 次
<input id="t1"type="text"/>
<input id="t2"type="text"/>
<input type="button"value="Replace"onclick="rep()"/>
<input type="button"value="Remove"onclick="rem()"/>
function rep(){t2.value=str.replace( t1.value."\n", "\n\n" );}
function rem(){t2.value=str.replace( t1.value."\n", " " );}
function rep(){t2.value = t1.value.replace(/\n/g,"\n\n");}
function rem(){t2.value = t1.value.replace(/\n/g,"" );}
<input type="text" id="t" value="abc
bcd" />
<script>
window.onload = function () {
alert(document.getElementById('t').value.length)//输出6
}
</script>