html>
<head>
<title>jQuerytitle>
<style>
button {
background-color: orange;
color: white;
border: 2px outset orange;
}
input, button {
outline: none;
}
#error {
color: red;
}
style>
<script sre="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous">script>
<script>
let onReady = function () {
jQuery('#error').hide();
jQuery('button').on('mousedown', function() {
jQuery(this).css('border-style', 'inset');
});
jQuery('button').on('mouseup', function() {
jQuery(this).css('border-style', 'outset');
let num1 = jQuery('#num1').val();
let num2 = jQuery('#num2').val();
num1 = Number(num1);
num2 = Number(num2);
if(isNaN(num1) || isNaN(num2)) {
jQuery('#error').fadeIn();
jQuery('#result').html(0);
} else {
jQuery('#error').fadeOut();
jQuery('#result').html(num1 + num2);
}
});
}
jQuery(onReady);
script>
head>
<body>
<input id="num1" type="text" size"5" />
<span>+span>
<input id="num2" type="text" size"5" />
<button type="button">=button>
<span id="result">0span>
<div id="error">Iltimos, raqam kiritingdiv>
body>
html>
Tayyorladi:_______________________________________Abdimo’minov.A
Do'stlaringiz bilan baham: |