var cont=$(this).children('.s1').html().replace(/<br>/ig,"\r\n");
if(window.clipboardData){
$('#copyButton_'+id).click(function(){
window.clipboardData.setData("Text",txt);
$('#hiddenHint').clone().appendTo($('body'))
.css({top:$('#copyButton_'+id).offset().top-55,left:$('#copyButton_'+id).offset().left})
.show().fadeOut(4000,function(){
$(this).remove();
});
return false;   
});在执行复制文本的时候,<br /> 变成了, fn输出文本了, 成这样了, fn122333334 fn1233333344 为什么不换行呢?
-----------------------下面的完整的JS----------------------------
<SCRIPT language=javascript type=text/javascript>$(document).ready(function(){//鼠标移动聚焦$('.list4').each(function(){var id=$(this).children(".diggs").attr('id').split('_')[1];$(this).mouseover(function(){$('#copy_'+id).css({visibility:''});$(this).css({ background: "#ffe6e6" });});$(this).mouseout(function(){$('.qm_copy').css({visibility:'hidden'});$(this).css({ background: "" });});var cont=$(this).children('.s1').text();if(window.clipboardData){$('#copyButton_'+id).click(function(){  window.clipboardData.setData("Text",cont);$('#hiddenHint').clone().appendTo($('body')).css({top:$('#copyButton_'+id).offset().top-55,left:$('#copyButton_'+id).offset().left}).show().fadeOut(4000,function(){$(this).remove();});return false;});}else{ $('#copyButton_'+id).zclip({path:'/j/ZeroClipboard.swf',copy:cont,afterCopy:function(){$('#hiddenHint').clone().appendTo($('body')).css({top:$('#copyButton_'+id).offset().top-55,left:$('#copyButton_'+id).offset().left}).show().fadeOut(4000,function(){$(this).remove();});}});}});});</SCRIPT>
--------------------------结束------------------------------------------------

解决方案 »

  1.   

    replace是用后面的字符串替换前面的符合匹配正则的字符窜!!!,貌似
      

  2.   

    var cont=$(this).children('.s1').html().replace(/<br\/?>/gi,"\\r\\n");
      

  3.   

    楼上的,不行哦~ 
    完全不能复制了,大侠们帮下忙阿
    我现这段JS可以复制文体,但遇到有换行的文本时,复制时候没换行!!!  我给代码
    var cont=$(this).children('.s1').text();
    改成这个
    var cont=$(this).children('.s1').html().replace(/<br>/ig,"\r\n");
    真接把\r\n输出成了rn文体,求解觉!!
      

  4.   

    day day up
    最后一次顶了,麻烦好心人回下,好让我在顶!
      

  5.   

    晕了
    alert(cont);就会看到换行了。
    控制字符,不是用在html中显示的。
    html标标中也没有\r或\n这个标记,在html中,段落内换行就是<br />