Lab 2
Lab 2
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive Elements</title>
<style>
/* Default style */
.styled-element {
color: blue;
font-size: 16px;
}
/* Alternate style */
.alternate-style {
color: red;
font-size: 20px;
font-weight: bold;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
</head>
<body>
<script>
// Requirement 1
function displayWelcome() {
alert('Welcome to the page!');
}
// Requirement 2
function changeBackgroundColor() {
document.getElementById('colorChangeInput').style.backgroundColor =
'yellow';
}
// Requirement 3 and 4
function toggleStyleProperties() {
$('#styledElement').toggleClass('alternate-style');
}
function changeStyle() {
$('#styledElement').removeClass('styled-element').addClass('alternate-
style');
}
// Requirement 5
function displayTextOnButton() {
var text = $('#textBox').val();
$('button').text(text);
}
</script>
</body>
</html>
OUTPUT SCREENSHOT: