Problem
You need to get or set the text that is contained inside of an HTML element(s).
Solution
jQuery provides the text() method for getting and setting the text content of elements.In the following code, we use this method to set and then get the text value of the <p>element found in the HTML document:
Running this code in a browser will result in a browser alerting the content of the <p>element, which we set using the text() method and then retrieved using the text() method.
Discussion
It’s important to remember that the text() method is not unlike html() except that the text() method will escape HTML (replace <and >with their HTML entities). This means that if you place tags inside of the text string passed to the text() method, it will convert these tags to their HTML entities (< and >).
|
|
J Query Related Interview Questions |
|
---|---|
HTML 4 Interview Questions | HTML Interview Questions |
HTML 5 Interview Questions | Zend Interview Questions |
PHP and Jquery Interview Questions | HTML+Javascript Interview Questions |
J Query Interview Questions | Javascript Objects Interview Questions |
Javascript Advanced Interview Questions | CodeIgniter Interview Questions |
JqueryUI Interview Questions | Dynamic HTML Interview Questions |
XQuery Interview Questions | jQuery Mobile Interview Questions |
JSON (JavaScript Object Notation) Interview Questions | Advanced jQuery Interview Questions |
J Query Related Practice Tests |
|
---|---|
HTML 4 Practice Tests | HTML Practice Tests |
HTML 5 Practice Tests | Zend Practice Tests |
PHP and Jquery Practice Tests | J Query Practice Tests |
CodeIgniter Practice Tests | Dynamic HTML Practice Tests |
JSON (JavaScript Object Notation) Practice Tests | Advanced jQuery Practice Tests |
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.