Examples of HTML (), text (), Val () differences in jquery are described in _jquery

Source: Internet
Author: User

1.HTML

HTML (): Gets the HTML content of the first matching element. This function is not available for XML documents. But can be used for XHTML documents
HTML (val): Sets the HTML content for each matching element. This function is not available for XML documents. But can be used for XHTML documents.

2.TEXT

Text (): Gets the contents of all matching elements.
The result is text that is combined with the text content contained by all matching elements. This method works for both HTML and XML documents.
Text (val): Sets the textual content of all matching elements
Similar to HTML (), but will encode HTML (replace "<" and ">" with the corresponding HTML entity).

3.VAL

Val (): Gets the current value of the first matching element.
Val (val): Sets the value of each matching element. The contents of the

are copied in the Help documentation for jquery, and are no more than nonsense. Here are some of the exercises you've done, the code is as follows:
While I was doing the exercise I found another different place for HTML and text
HTML () to the content of the elements, the selected elements of the following format can also be taken.
such as: <div id= "Divshow" ><b><i>write less do more</i></b></div>
If we use Var strHTML = $ ("#divShow"). html ();
The result is: <b><i>write less do more</i></b>
If we use Var StrHTML2 = $ ("#divShow b I"). html ();
The result is write less do
and text does not have the first case,
if we var strText = $ ("#divShow"). Te XT ();
result is write less do more

<%@ page language= "java" import= "java.util.*" pageencoding= "Utf-8"%> <% String Path = Request.getcontextpath ()
;
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/"; %> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >  

Everyone can also go to the verification, the above is my experiment, I use jquery is 1.6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.