coduri pentru js
DESCRIPTION
coduriTRANSCRIPT
![Page 1: Coduri Pentru Js](https://reader035.vdocument.in/reader035/viewer/2022072007/55cf8ee6550346703b96c983/html5/thumbnails/1.jpg)
CODURI PENTRU JS:
1)Afisare data si ora
<button type="button"
onclick="document.getElementById('demo').innerHTML = Date()">
Click me to display Date and Time.</button>
<p id="demo"></p>
2)
<p id="demo">JavaScript can change HTML content.</p>
<button type="button"
onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!'">
Click Me!</button>
3)Beculet(aprins/inchis)
<img id="myImage" onclick="changeImage()" src="pic_bulboff.gif" width="100" height="180">
<p>Click the light bulb to turn on/off the light.</p>
<script>
function changeImage() {
var image = document.getElementById('myImage');
if (image.src.match("bulbon")) {
image.src = "pic_bulboff.gif";
} else {
image.src = "pic_bulbon.gif";
}
}</script>
4)Schimbare de font
<p id="demo">JavaScript can change the style of an HTML element.</p>
![Page 2: Coduri Pentru Js](https://reader035.vdocument.in/reader035/viewer/2022072007/55cf8ee6550346703b96c983/html5/thumbnails/2.jpg)
<script>
function myFunction() {
var x = document.getElementById("demo");
x.style.fontSize = "25px";
x.style.color = "red";
}
</script>
<button type="button" onclick="myFunction()">Click Me!</button>
5)Calcul suma pana la n
<p>Calculez suma primelor n elemente. Introduceti n-ul</p>
<input id="numb" type="number">
<button type="button" onclick="myFunction()">Submit</button>
<p id="demo"></p>
<script>
function myFunction() {
var x,y, suma=0;
x = document.getElementById("numb").value;
for(y=1;y<=x;y++)
{suma=suma+y;}
document.getElementById("demo").innerHTML = suma;
}
</script>
6)Fereastra alerta
<script>window.alert(5 + 6);</script>
7)Introduc variabile
![Page 3: Coduri Pentru Js](https://reader035.vdocument.in/reader035/viewer/2022072007/55cf8ee6550346703b96c983/html5/thumbnails/3.jpg)
var x = 5;var y = 6;var z = x + y;8)Introduce un numar<script>document.getElementById("demo").innerHTML = 10.50;</script>