Assignment no-3 web tech
Set A
Q1 ans
[Link] = function() {
alert("Exams are near, have you started preparing for?");
let response = prompt("Have you started preparing? (Yes/No)");
if (response && [Link]() === "yes") {
alert("Great! Keep it up.");
} else {
let confirmStudy = confirm("Would you like to start preparing now?");
if (confirmStudy) {
alert("Good decision! Start studying now.");
} else {
alert("You should start soon to do well in exams.");
}
}
};
Q2 ans
<!DOCTYPE html>
<html lang="en">
<head>
<title>Append Example</title>
<script src="[Link]
</head>
<body>
<p id="para">This is a paragraph.</p>
<ol id="list">
<li>Item 1</li>
<li>Item 2</li>
</ol>
<button id="addText">Append Text</button>
<script>
$(document).ready(function() {
$("#addText").click(function() {
$("#para").append(" More content added.");
$("#list").append("<li>New List Item</li>");
});
});
</script>
</body>
</html>
Set B
Q2 ans
<!DOCTYPE html>
<html lang="en">
<head>
<title>Insert Text</title>
<script src="[Link]
</head>
<body>
<button id="addText">Insert Text</button>
<br><br>
<img id="myImage" src="[Link]" alt="Sample Image" width="200">
<script>
$(document).ready(function() {
$("#addText").click(function() {
$("#myImage").before("<p>Text Before Image</p>");
$("#myImage").after("<p>Text After Image</p>");
});
});
</script>
</body>
</html>
Set C
Q2 ans
<!DOCTYPE html>
<html lang="en">
<head>
<title>Remove Div</title>
<script src="[Link]
</head>
<body>
<div id="content">
<p>This is a paragraph inside a div.</p>
<button id="removeDiv">Remove Section</button>
</div>
<script>
$(document).ready(function() {
$("#removeDiv").click(function() {
$("#content").remove();
});
});
</script>
</body>
</html>