jQuery Get Methods are used to retrieve information from HTML elements or form fields easily and efficiently.
.html() retrieves the HTML content inside an element.
.text() retrieves only text without HTML tags.
.attr(attributeName) retrieves attribute values.
.val() retrieves values from form elements.
// Getting different values using jQuery get methods
let html = $("#myDiv").html();
let text = $("#myDiv").text();
let href = $("#myLink").attr("href");
let inputVal = $("#myInput").val();
Type something with tags (e.g., <b>Bold</b>) below to see the difference in real-time:
Each button triggers a jQuery get method and displays the retrieved value dynamically.
.val() for form fields only..html() includes tags, .text() does not.