Skip to the content.

Angular > jQuery


jQuery Library

Get started with jQuery, the fast, small, and feature-rich JavaScript library. Learn how to simplify DOM manipulation, handle events, and work with AJAX efficiently.


๐Ÿ“ฆ jQuery Basics

    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
    <script>
      $(document).ready(function () {
        console.log("DOM is ready!");
      });
    </script>

๐ŸŒ DOM Manipulation


    $("#title").text("Updated Title");
    $("#box").css("background-color", "lightblue");
    $("ul li").first().append("<span> โœ”๏ธ</span>");


๐Ÿ–ฑ๏ธ Events & Handlers

    $("#btn").click(function () {
      alert("Button clicked!");
    });

    $("ul").on("click", "li", function () {
      $(this).toggleClass("done");
    });

๐Ÿ“ก AJAX with jQuery

    $.get("/api/data", function (response) {
      $("#result").html(response);
    });

    $.ajax({
      url: "/api/submit",
      method: "POST",
      data: { name: "John" },
      success: function (res) {
        console.log("Success:", res);
      },
      error: function (err) {
        console.error("Error:", err);
      }
    });

๐Ÿงช Utilities & Effects

    $("#box")
      .fadeOut(500)
      .fadeIn(500)
      .css("border", "2px solid green");

    $.each(["Apple", "Banana"], function (index, value) {
      console.log(index + ": " + value);
    });

References


๐Ÿ”— Related Topics: