Wie kopiert man einen text aus <output> in die Zwischenablage

Ich habe dieses Formular:

<table>
  <tr>
    <th>
      Attribute
    </th>
    <th>
      Cluster
    </th>
  </tr>
  <tr>
    <td>
      <input type="text" id="attributeZigbee">
    </td>
    <td>
      <input type="text" id="clusterZigbee">
      <input id="attributeBt" type="button" onclick="getAttributeClusterZigbee()" value="Ok">
    </td>
  </tr>
  <tr>
    <td colspan="2" class="result">
      <output id="attributeClusterDesc"></output>
    </td>
  </tr>
</table>
<button onclick="copyOutputZigBee()">Copy</button>
<br>

Diese form gibt mir ein bestimmtes Ergebnis durch die Funktion:

function getAttributeClusterZigbee() {
  att = document.getElementById("attributeZigbee").value;
  clu = document.getElementById("clusterZigbee").value;
  if (att == 0) {
    document.getElementById("attributeClusterDesc").innerHTML = "Please fill the <b>Attribute</b> field";
  } else if (att != 0 && clu == 0) {
    document.getElementById("attributeClusterDesc").innerHTML =
      "<br>zclPayload.attributeId_attribute_id_0 == " + att + " || <br> zclPayload.attributeId_attribute_id_1 == " + att + " || <br> zclPayload.attributeId_attribute_id_2 == " + att + " || <br> zclPayload.attributeId_attribute_id_3 == " + att + "|| <br> zclPayload.attributeId_attribute_id_4 == " + att + "||<br> zclPayload.attributeId_attribute_id_5 == " + att + "|| <br> zclPayload.attributeId_attribute_id_6 == " + att + " || <br> zclPayload.attributeId_attribute_id_7 == " + att + " || <br> zclPayload.attributeId_attribute_id_8 == " + att + " || <br> zclPayload.attributeId_attribute_id_9 == " + att + "|| <br> zclPayload.attributeId_attribute_id_10 == " + att + "|| <br> zclPayload.attributeId_attribute_id_11 == " + att + " || <br> zclPayload.attributeId_attribute_id_12 == " + att + " ||<br> zclPayload.attributeId_attribute_id_13 == " + att + " || <br> zclPayload.attributeId_attribute_id_14 == " + att + " || <br> zclPayload.attributeId_attribute_id_15 == " + att + " || <br> zclPayload.attributeId_attribute_id_16 == " + att + " || <br> zclPayload.attributeId_attribute_id_17 == " + att + " || <br>zclPayload.attributeId_attribute_id_18 == " + att + " || <br>zclPayload.attributeId_attribute_id_19 ==" + att + " "
  } else if (att != 0 && clu != 0) {
    document.getElementById("attributeClusterDesc").innerHTML =
      "<br>(zclPayload.attributeId_attribute_id_0 == " + att + " || <br> zclPayload.attributeId_attribute_id_1 == " + att + " || <br> zclPayload.attributeId_attribute_id_2 == " + att + " || <br> zclPayload.attributeId_attribute_id_3 == " + att + "|| <br> zclPayload.attributeId_attribute_id_4 == " + att + "||<br> zclPayload.attributeId_attribute_id_5 == " + att + "|| <br> zclPayload.attributeId_attribute_id_6 == " + att + " || <br> zclPayload.attributeId_attribute_id_7 == " + att + " || <br> zclPayload.attributeId_attribute_id_8 == " + att + " || <br> zclPayload.attributeId_attribute_id_9 == " + att + "|| <br> zclPayload.attributeId_attribute_id_10 == " + att + "|| <br> zclPayload.attributeId_attribute_id_11 == " + att + " || <br> zclPayload.attributeId_attribute_id_12 == " + att + " ||<br> zclPayload.attributeId_attribute_id_13 == " + att + " || <br> zclPayload.attributeId_attribute_id_14 == " + att + " || <br> zclPayload.attributeId_attribute_id_15 == " + att + " || <br> zclPayload.attributeId_attribute_id_16 == " + att + " || <br> zclPayload.attributeId_attribute_id_17 == " + att + " || <br>zclPayload.attributeId_attribute_id_18 == " + att + " || <br>zclPayload.attributeId_attribute_id_19 == " + att + ")<br>&& zigbeeApplicationSupport.clusterIdV2 ==" + clu + "";
  }
}

Das Ergebnis ist in der Ausgabe angezeigt-tag und ich möchte in der Lage sein, zu kopieren, dass Inhalte, clip-board, nachdem ich das Ergebnis bekommen....

+3
2019-09-19 18:17:33
Quelle

Sehen Sie sich andere Fragen zu Tags an