Advanced jQuery Techniques

Chaining Methods

$("#box").css("color", "red").slideUp(1000).slideDown(1000);

Deferred Objects and Promises

$.when($.ajax("https://api.example.com/data"), $.ajax("https://api.example.com/info"))
    .done(function(response1, response2) {
        console.log("Both requests completed successfully");
    })
    .fail(function() {
        console.log("An error occurred");
    });

Performance Optimization Tips

$("#parent").on("click", "button", function() {
    alert("Efficient event handling!");
});
var $box = $("#box");
$box.css("background", "blue").fadeIn(500);
$("#element").data("key", "value");