codeGK
Code it ALL
jQuery Get - CodeGK
♦ jQuery Get

♣ About jQuery Get

jQuery get() method gives a way to fetch data from HTML elements of particular type.
There are broadly four categories of data fetch methods, namely text(), html(), val() and attr().

♣ Example1: jQuery get html()

Returns the HTML content of selected HTML element, i.e, the output will also have tags along with text.
Below is the representation of jQuery get html() Syntax.
Basic Syntax
$(selector).html();
selector: the HTML element to be selected
html(): syntax for selecting text with html tags.
In this example, .
Example
Input:
Output:

♣ Example2: jQuery get text()

Returns the Textual content of selected HTML element, i.e, the output will only be having text and the tags will be ignored.
Below is the representation of jQuery get text() Syntax.
Basic Syntax
$(selector).text();
selector: the HTML element to be selected
text(): syntax for selecting on text and ignoring html tags.
In this example, .
Example
Input:
Output:

♣ Example3: jQuery get val()

Returns the Value content of selected HTML element from the form.
Below is the representation of jQuery get val() Syntax.
Basic Syntax
$(selector).val();
selector: the HTML element to be selected
val(): syntax for selecting value from form input.
In this example, .
Example
Input:
Output:

♣ Example4: jQuery get attr()

Returns the Attribute content of selected HTML element from selected attribute.
Below is the representation of jQuery get attr() Syntax.
Basic Syntax
$(selector).attr(attribute_selector)
selector: the HTML element to be selected.
attr(): syntax for selecting attribute value from HTML element.
attribute_selector: the attribute selector for the HTML element.(eg, href, src, etc)
In this example, .
Example
Input:
Output:
Prev_LessonNext_Lesson