Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Answers


The text() method sets or returns the text content of the selected elements.

Syntax:

$(".element-classname").text();

Note it returns content of all matched elements.

Code sample:

Following code will return text content from search result div,

a.  Using Id selector, it will return text for specific div

$('#divSearchResult').text();

b. Using class selector, it will return text of all matching div elements

$('.search-result').text();

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.