Necesito implementar algo como Tema de palabras clave de Google que haga clic en el signo más para almacenar el valor del div en una matriz. El problema es que solo copia el primer valor impreso.
Este es el código php
echo "<div id=\"copying_keywords\" class=\" shadow-lg bg-body rounded border border-3 border-dark rounded-pill overlay view zoom hover-zoom\" style=\"opacity:0.7; display:inline-block; padding:5px; margin:1px; color:black; background: #3f729b; border: 1px solid #847577; border-radius:50px;\"> ". $Youtube_tags_arr[$j + $i] . " <button id=\"keywords\" onclick=\"func_keywords()\" type=\"button\" class=\"btn btn-default btn-sm\"> <span class=\"\"></span> <i class=\"fa-solid fa-plus\"></i> </button> </div>";Este es el Código Javascript 6
<script type="text/javascript"> function func_keywords(){ alert('helllo there'); if (window.getSelection) { if (window.getSelection().empty) { // Chrome window.getSelection().empty(); } else if (window.getSelection().removeAllRanges) { // Firefox window.getSelection().removeAllRanges(); } } else if (document.selection) { // IE? document.selection.empty(); } if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById("copying_keywords")); range.select().createTextRange(); document.execCommand("copy"); alert(range); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(document.getElementById("copying_keywords")); window.getSelection().addRange(range); document.execCommand("keywords"); alert(range); } } </script> Así es como funciona cualquiera que sea el signo más, lo presiono copia solo el primer valor 