1
I need to provide a button where users will just click and copy all the code that was used to develop that page.
I’ve seen a lot of similar questions, but none of them have solved my problem. It would be basically like this, imagine that the code example below corresponds to the page I need to copy:
<div class="conteudo-total">
<div>
<h1>Titulo</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam laboriosam inventore blanditiis repellendus corrupti, ea, maxime magnam odio, vero consequatur, dolores hic. Accusantium voluptatem nulla velit, deserunt sequi eveniet debitis.</p>
</div>
</div>
<div class="copiar">Copiar Código</div>
When you click Copiar Código
I need to copy all content html
, that is, the entire contents of the file. I know it would be much simpler to go into the archive and copy the code directly from there, but it is an indispensable requirement that it be through a button...
Can use
JQuery
?– Roberto de Campos
Yes, I even tried some jQuery shapes, but I couldn’t.
– Julio Cesar
Yeah, but, hey? It’s gonna stick where that?
– Julio Henrique
if it’s just the html css and js of the page you can use var code = Document.body.innerHTML;
– Anderson Henrique
Julio Henrique, will be pasted in other projects, for being a model page
– Julio Cesar
Good, Anderson, I hadn’t thought of it. But you would know how to copy the contents of this variable code, as if it were a Ctrl+c?
– Julio Cesar