Event Handling

jQuery simplifies event handling for various user interactions.

$("#btn").click(function() {
    alert("Button Clicked!");
});
$("#box").mouseenter(function() {
    $(this).css("background-color", "lightblue");
});
$("#box").mouseleave(function() {
    $(this).css("background-color", "white");
});
$("#inputField").keypress(function(event) {
    console.log("Key pressed: " + event.key);
});
$("#parent").on("click", "button", function() {
    alert("Dynamically added button clicked!");
});