Print separate but same id Divs

Asked

Viewed 82 times

1

I would like a script to print one div separate from the other that has the same id ex.:

<div id="print">
<p>Imprimir este conteúdo separado das outras div</p>
<input type="buttom" value="Imprimir">
</div>

<div id="print">
<p>Imprimir este conteúdo separado das outras div</p>
<input type="buttom" value="Imprimir">
</div>

<div id="print">
<p>Imprimir este conteúdo separado das outras div</p>
<input type="buttom" value="Imprimir">
</div>
  • The ids should be single per page... Consider doing a [tour] and adjusting your question as explained in [help]. Good Luck!

1 answer

1


See if it works:

        <script>
function imprimir(mesmo){
    var conteudo = mesmo.parentElement.innerHTML,
        tela_impressao = window.open('about:blank');

    tela_impressao.document.write(conteudo);
    tela_impressao.window.print();
    tela_impressao.window.close();
}
</script>

<div id="print">
<p>Imprimir este conteúdo separado das outras div</p>
<input type="button" value="Imprimir" onclick="imprimir(this);">
</div>

<div id="print">
<p>Imprimir este conteúdo separado das outras div</p>
<input type="buttom" value="Imprimir" onclick="imprimir(this);">
</div>

<div id="print">
<p>Imprimir este conteúdo separado das outras div</p>
<input type="buttom" value="Imprimir" onclick="imprimir(this);">
</div>
  • I think this will tested it alone worked! I will play in my application and warn you...

  • 1

    PERFECT OOOO!!!! IT WORKED MY FRIEND! THANK YOU SO MUCH! NOTE 10!

  • Put a joinha then in my reply doing favor...

  • Ready! Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.