Initial commit

parents
This diff is collapsed.
// Task1_2
var score = parseInt($('#number').html());
$(function() {
$('#btn').click(function() {
score++;
$('#number').html(score);
});
setTimeout(function() {
alert("Counter is cleared");
$('#number').html(0);
}, 30000);
});
//Task3
function getSum() {
var first = document.getElementById("first_num").value;
var second = document.getElementById("second_num").value;
var result = parseInt(first) + parseInt(second);
$("#result").html(result);
}
function getMultiply() {
var first = document.getElementById("first_num").value;
var second = document.getElementById("second_num").value;
var result = parseInt(first) * parseInt(second);
$("#result").html(result);
}
function getDecrease() {
var first = document.getElementById("first_num").value;
var second = document.getElementById("second_num").value;
var result = parseInt(first) - parseInt(second);
$("#result").html(result);
}
function getDivision() {
var first = document.getElementById("first_num").value;
var second = document.getElementById("second_num").value;
var result = parseInt(first) / parseInt(second);
$("#result").html(result);
}
//Task4
$(function() {
var colors = ["orange", "yellow", "green", "deepskyblue", "blue", "darkviolet"];
var width = 20;
var time = 0;
for (i = 0; i < colors.length; i++) {
(function(i) {
time = time + 15000;
width = width + 20;
var item = $('<div></div>').css({ 'background-color': colors[i], width: width, height: 20 });
setTimeout(function() {
$('body').append(item);
}, time);
})(i);
};
setTimeout(function() {
alert("Rainbow is complete!");
}, time + 500);
});
\ No newline at end of file
<!DOCTYPE html>
<html lang="en-us">
<head>
<title>task1_2</title>
</head>
<body>
<p id="number">1</p>
<button id="btn">click</button>
<script src="js/jquery-3.3.1.js"></script>
<script src="js/script.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Task3</title>
</head>
<body>
<form>
<input type="number" id="first_num">
<input type="number" id="second_num">
<input type="button" onclick="getSum()" value="+">
<input type="button" onclick="getDecrease()" value="-">
<input type="button" onclick="getMultiply()" value="*">
<input type="button" onclick="getDivision()" value="/">
</form>
<p>Result is: <span id="result"></span> </p>
<script src="js/jquery-3.3.1.js"></script>
<script src="js/script.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en-us">
<head>
<title>Task4</title>
</head>
<body>
<div style="width: 20px; height: 20px; background-color:red;"></div>
<script src="js/jquery-3.3.1.js"></script>
<script src="js/script.js"></script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment