如何调整复制按钮/功能的复制格式?

问题描述 投票:0回答:0

我有这个html代码:

    <div id="people-sheet">
    <div class="stats-people">
<table>
  <tr>
    <td id="inplaceStr">Strength</td>
    <td id="pointerStr">-</td>
  </tr>
  <tr>
    <td id="inplaceSpd">Speed</td>
    <td id="pointerSpd">-</td>
  </tr>
    <tr>
    <td id="inplaceDex">Dexterity</td>
    <td id="pointerDex">-</td>
  </tr>
    <tr>
    <td id="inplaceDur">Durability</td>
    <td id="pointerDur">-</td>
  </tr>
    <tr>
    <td id="inplaceEnd">Endurance</td>
    <td id="pointerEnd">-</td>
  </tr>
    <tr>
    <td id="inplaceSen">Senses</td>
    <td id="pointerSen">-</td>
  </tr>
    <tr>
    <td id="inplaceInt">Intellect</td>
    <td id="pointerInt">-</td>
  </tr>
    <tr>
    <td id="inplaceWil">Willpower</td>
    <td id="pointerWil">-</td>
  </tr>
    <tr>
    <td id="inplaceCha">Charisma</td>
    <td id="pointerCha">-</td>
  </tr>
</table>
    </div>

    <div class="skills-people">
    <p class="skills-list">Skills Ranks: </p> <p id="p-rankcap">Rank Cap: </p>
    <textarea rows="10" cols="50" id="p-skills"></textarea></p>
    </div>

    <div class="equipment-people">
      <p>Equipment:</p>
      <textarea class="equipment-text-area" rows="10" cols="50" placeholder="Remove and Add at your discretion."></textarea>
    </div>

    <div class="traits-people">
      <p>Traits:</p>
      <textarea class="trait-text-area" rows="10" cols="50" placeholder="Remove and Add at your discretion."></textarea>
    </div>

    <div class="racial-traits-people">
      <p>Racial Traits:</p>
      <textarea class="racial-trait-text-area" rows="10" cols="50" placeholder="Remove and Add at your discretion."></textarea>
    </div>
  </div>

这个复制按钮功能:

$(document).ready(function () {

  $("#copy").click(function(){
    console.time('time1');
    var temp = $("<input>");
    $("body").append(temp);
   temp.val($('#people-sheet').text()).select();
    document.execCommand("copy");
    temp.remove();
      console.timeEnd('time1');
  });

});

但它是这样复制的:

      Strength    -        Speed    -          Dexterity    -          Durability    -          Endurance    -          Senses    -          Intellect    -          Willpower    -          Charisma    -              Skills Ranks:  Rank Cap:                   Equipment:                    Traits:                    Racial Traits:            

如何获取它来复制这样的内容:

强度-

速度 -

灵巧-

耐用性 -

耐力-

感官 -

智力-

意志力-

魅力-

技能等级:

等级上限:

设备:

特性:

种族特征:

包括文本区域的内部。

html jquery formatting copy-paste
© www.soinside.com 2019 - 2024. All rights reserved.