0% found this document useful (0 votes)
3 views2 pages

34

Uploaded by

galeznikdaniil08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

34

Uploaded by

galeznikdaniil08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

‹!

DOCTYPE html>
<html lang="en" >
<head ›
‹meta charset="UTF-8">
‹title>jQuery Example‹/title>
‹script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
‹style>
.square { width: 50px;height: 50px;
margin: 10px;border: 1px solid • #000;
position: relative; padding: 2px; }
‹/style>
</head>
< body >
< form id="colorForm">
‹ label><input type="checkbox" name="redCheckbox" value="red"›Красный</label>
‹ label><input type="checkbox" name="blueCheckbox" value="blue"› Синий</label>
‹ label><input type="checkbox" name="greenCheckbox"
value="green"›Зеленый</label>
‹ label><input type="checkbox" name="yellowCheckbox" value="yellow"›
Желтый</label><br>
< label><input type="radio" name="moveRadio" value="red"> Красный</label >
< label><input type="radio" name="moveRadio" value="blue"> Синий</label >
< label><input type="radio" name="moveRadio" value="green"> Зеленый</label >
< label><input type="radio" name="moveRadio" value="yellow"> Желтый</label >
</ form>
<div id="redSquare" class="square"></div>
‹div id="blueSquare" class="square"></div>
‹div id="greenSquare" class="square"></div>
«div id="yellowSquare" class="square"></div><br>
< button type="button" id="clearButton">Очистить</button>
< script>
$(document). ready(function () {
function changeColor(squareld, color) {
$("#" + squareld).animate({ left: '+=50px' }, 'slow', function() {
console.log("Анимация завершена");
});
}
// Обработчик события для чекбоксов
$(": checkbox").change(function () {
var color = $(this).val();
var squareld = color + "Square";
if ($(this).prop("checked")) {
changeColor(squareid, "");
} else {
changeColor (squareld, "");
}
});
$(":radio").change(function () {
var color = $(this).val();
var squareld = color + "Square";
moveSquare (squareld);
});|
$("#clearButton").click(function () {
$(".square").css("background-color", "");
$(". square").css("left", "0");
});
$(":radio: checked"). trigger ("change");
});
</script›
</body>
‹/html»

You might also like