Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
How to copy multiple div content which is next to the plus sign in Javascript or PHP

I need to implement something like Google Keywords Theme that click the plus sign to store the value of the div in an array. The problem it just copies the first printed value only.

This's the php code

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>";

This is the Javascript Code 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>

This's how it works whatever the plus sign I press it copies only the first value enter image description here

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda