WT - Oral Questions
WT - Oral Questions
WT - Oral Questions
6. How can you manipulate HTML content using jQuery? Provide a simple example.
• You can use jQuery's .html() or .text() methods to change content. Example:
$("#element").html("New content");
7. What is the purpose of AJAX in JavaScript?
• AJAX allows you to send and receive data asynchronously without refreshing
the page.
8. How can you validate an HTML form using JavaScript? Write a simple code.
• Example:
function validateForm() {
var name = document.forms["myForm"]["name"].value;
if (name == "") {
alert("Name must be filled out");
return false;
}
}
9. What is the use of the event object in JavaScript?
• The event object contains information about the event that triggered an action,
such as the type of event or the element that was clicked.
10. Write a program demonstrating JavaScript loops and explain the
output. • Example:
for (var i = 0; i < 3; i++) {
console.log(i);
}
• Output: 0, 1, 2 (the loop runs 3 times, printing the values of i as it increments).