Cześć,
Proszę o pomoc chciałbym aby po kliknięciu buttoba zamiast diva "tetetstowy" pojawiła się ta konsola.
Poniżej zamieszczam cały kod
Próbowałem zrobić to za pomocą get.Element i innerHTML ale jak sami możecie zobaczyć zamienia się sam kod a nie wywołanie funkcji co tu jest źle ;/
var typing = document.querySelector('.typing'),
currentIndex = 0;
var startTyping = function (text) {
var interval = setInterval(function(){
if (text.length > currentIndex) {
typing.textContent += text[currentIndex];
currentIndex++;
} else {
clearInterval(interval);
}
},100);
}
startTyping("[root@28.3.4.53.2]");
function podmianka() {
var a = document.getElementsByClassName("tetestowy");
a[0].innerHTML= startTyping;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="stylekonsola.css">
<title>
TEST
</title>
</head>
<body>
<div class="console">
<pre class="typing">$ </pre>
</div>
<div class="tetestowy">
<h1>Tetowa Strona </h1>
<p>rererere heheheh ssadasdasdvadv</p>
<button onclick="podmianka()">Try it</button>
<script src="scriptkosnola.js"> </script>
</body>
</html>
.console {
background: #000000;
height: 400px;
width: 600px;
border: 3px solid #c0c0c0;
padding: 10px;
border-top-width: 20px;
position: relative;
border-radius: 3px;
}
.console::before {
content: '';
width: 10px;
height: 10px;
position: absolute;
background: #ff0000;
border-radius: 50%;
top: -15px;
left: 3px;
}
.console::after {
content: '';
width: 10px;
height: 10px;
position: absolute;
background: #ffa500;
border-radius: 50%;
top: -15px;
left: 15px;
}
.typing {
color: #34d834;
margin: 0;
}
.typing::before {
content: 'user@rootadmin.je : ~';
display: block;
}
.typing::after {
content: '_';
animation: blink 0.6s infinite;
}
@keyframes blink {
0%, 49% { opacity: 0; }
50%, 99% { opacity: 1; }
}