JS Magic Hall: Re-recognize ASCII entities, symbol entities, and character entities

Source: Internet
Author: User

First, preface

I believe you are familiar with the character   to achieve multiple consecutive spaces input bar! This article intends to three kinds of HTML entities and JS related operations for further collation and summary, if there are flaws please correct me, thank you.

Second, the first knowledge of HTML entities

Because some characters in HTML are reserved (such as >, <, and so on), to display the reserved characters correctly after parsing the HTML, you need to use a character entity instead.

Character entities are represented in two ways:

// entity name &entity_name; // entity number & #entity_number;

Entity name benefits are easy to remember, but not all browsers can recognize all entity names.

All the entity numbers are recognized by all browsers.

Note: The entity name is case sensitive Oh!

Three, 3 types of entities

Entities are divided into ASCII entities, character entities, and symbol entities. Please refer to the HTML iso-8859-1 Reference manual for details.

For the use of each entity please refer to @ Zhang Xin Asahi's "Web page related to some of the common characters of the introduction", here to borrow a bit about the space character portion of the content.

&nbsp; , which is the space key. The width is affected by the font and is destroyed in the Inline-block layout, but is necessary in the justify layout.

&ensp; , 1/2 medium character width, and the width is not affected by the font.

&emsp; , 1 Chinese characters are width, and the width is not affected by the font.

&thinsp; , I do not know what is the use of space.

Iv. manipulating entities through outerhtml,innerhtml,innertext,textcontent and value

First we need to divide 3 entity types into two classes, one for ASCII entities and one for character and symbol entities.

for ASCII entities

1. outerHTML and innerHTML of non-form elements can only get entity name or entity number;

2. Ie/chrome the innertext of non-form elements can obtain the corresponding characters;

3. Ie9+/ff/chrome the textcontent of non-form elements can obtain the corresponding characters;

4. The textarea value can be used to obtain the corresponding character.

For character entities and symbol entities

Only the corresponding characters can be obtained and the entity name and entity number cannot be obtained directly.

V. Summary

Please correct me if there is any mistake, thank you.

Respect the original, reprint please indicate from: http://www.cnblogs.com/fsjohnhuang/p/4319483.html ^_^ Fat Boy John

JS Magic Hall: Re-recognize ASCII entities, symbol entities, and character entities

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.