Professional Documents
Culture Documents
Event Listener
Event Listener
Event Listener
<script>
document.getElementById("myBtn").addEventListener("
dblclick",function()
{
alert('hey there');
});
</script>
</body>
</html>
document.getElementById("butoniInkremento").addEve
ntListener("click",inkremento,false);}
function inkremento() {
numeruesi+=2;
document.getElementById("numero").innerHTML=
numeruesi; }
window.addEventListener( "load", start, false );
</script>
</body>
VOLUMI SFERES
<html>
<body>
<label>Rrezja</label>
<input type="number" id="rrezja"/>
<button id="volumi"> Volumi </button>
<script>
function start(){
document.getElementById("volumi").addEventListener(
"click",calculate,false);}
function calculate(){
var rrezja=document.getElementById("rrezja").value;
var rrezja=parseInt(rrezja);
var volumi=( 4.0 / 3.0 ) * Math.PI *
Math.pow( rrezja, 3 );
alert("Volumi i sferes eshte"+volumi); }
window.addEventListener( "load", start, false );
</script> </body> </html>
<html>
<body>
<label> Ore ne garazh </label>
<input type="number" id="ore"/>
<button id="pagesa"> Pagesa</button>
<p id="rezultati"> </p>
<p id="totali"> </p>
<script>
window.addEventListener("load",start,false);
function start(){
document.getElementById("pagesa").addEventListener(
"click",llogarit,false); }
function llogarit(){
var ore=document.getElementById("ore").value;
var ore=parseInt(ore);
var shuma=0;
var totali=0;
while(ore!==-1){
if (ore<=3) {
shuma=2;
totali=totali+shuma;
} else if (ore>24) {
shuma=10;
totali=totali+shuma;
} else {
shuma=2+(ore-3)*0.5;
totali=totali+shuma;
}…vazhdon me poshte
document.getElementById("rezultati").innerHTML =
"Klienti ka paguar:"+shuma;
document.getElementById("totali").innerHTML =
"Totali eshte:"+totali;
ore=document.getElementById("ore").value;
}}
</script> </body> </html>
<script>
window.addEventListener("load",start,false);
function start() {
document.getElementById("rezultati").
addEventListener("click",integerPower,false);
}
function integerPower(){
var baza=document.getElementById("baza").value;
var baza=parseInt(baza);
var eksponenti=document.getElementById
("eksponenti").value;
var eksponenti=parseInt(eksponenti);
var rezultati=1;
for(var i=1;i<=eksponenti;i++){
rezultati=rezultati*baza;
}
document.getElementById("final").innerHTML
="Rezultati eshte:"+rezultati;
}
</script>
</body>
</html>
<script>
window.addEventListener("load",start,false);
function start(){
document.getElementById("gjej").addEventListener
("click",multiple,false); }
function multiple(){
var ipari=parseInt(document.getElementById
("pari").value);
var idyti=parseInt(document.getElementById
("dyti").value);
if (idyti%ipari==0){
document.getElementById("rezultati").innerHTML=true;
} else {
document.getElementById("rezultati").innerHTML=false
;} }
</script>
</body>
</html>