First, prefaceSince innertext is not a standard property, we cannot use it in Firefox, and we can generally use textcontent instead, but can it be exactly the same? Is it still weird in the form elements of the pit daddy (such as input, textarea,
First, prefaceSince innertext is not a standard property, we cannot use it in Firefox, and we can generally use textcontent instead, but can it be exactly the same? Is it still weird in the form elements of the pit daddy (such as input, textarea,
Differences between textContent and innerTextIE has an innerText attribute, and FF has a textContent attribute. Many of the scripts previously written to IE cannot find the innerText attribute under FF. Therefore, we recommend that you use
The difference between textcontent and innertext
There is a innertext property under IE, FF has a textcontent attribute. Many of the former to write to IE script, in the FF can not find the innertext attribute, so the internet found the suggestion
Today, I encountered a compatibility problem when using innerText. FireFox does not support the innerText method. I checked the MDN and found that there is a similar method named textContent in FireFox, which is similar to the innerText in IE, is
InnerHTMLouterHTML; innerTextouterText; textContent-GentleMint innerHTML v. s. outerHTML
Element. innerHTML
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
Functionality
Get serialized HTML code
Innertext is a private Implementation of IE, but it is also implemented by browsers other than ff. textcontent is the W3C standard API. Now ie9 is also implemented.
There are only two differences between them.
Innertext cannot return the
The innerHTML property is used to read or set the HTML code within a node.When the outerHTML property is used to read or set HTML code, the node itself is included.The Textcontent property is used to read or set the text content that the node
This article mainly introduces the innerHTML attribute, outerHTML attribute, textContent attribute, and innerText attribute differences in javascript. it is a summary of my personal experience and I hope you will like it. The innerHTML attribute is
This article mainly introduced the JavaScript innerHTML attribute, outerhtml attribute, textcontent attribute, innertext attribute difference detailed explanation, all is the personal experience summary, shares to everybody, hoped everybody can like.
The innerHTML property is used to read or set the HTML code within a node.
When the outerHTML property is used to read or set the HTML code, the node itself is included.
The Textcontent property is used to read or set the text content that the
Today in the use of innertext encountered a compatibility problem, Firefox does not support InnerText method, check the next mdn, found that Firefox has a similar method, called textcontent, it and IE innertext similar, Is the method used to get
Read a lot of blog on the Internet to introduce the difference between them, most of them said that FF innertext can not be used, but after their own experiments, is available, so they summed up a variety of situations.
The first is innerHTML, this
In IE and opear, DOM objects support the innertext attribute and can easily remove HTML tags.
However, Firefox does not support this attribute. Fortunately, DOM objects in FF support textcontent, which is equivalent to innertext.
Demo instance:
innerHTML is a property of an object that is typically used to write to an existing label, or to read the contents of a label.InnerText is a property of an object that can be used only to write content, or to read content, not to read tags in the
Today, I modified a bug. The strange problem is that IE normal FF is not normal. I asked the experts next to me to know that FF uses textcontent to implement functions similar to innertext. The textcontent attribute is different from the innertext
TextContent is equivalent to innerText in Firefox in IE and Opear. DOM objects support the innerText attribute and can easily remove HTML tags.
However, Firefox does not support this attribute. Fortunately, DOM objects in FF support textContent,
Value is the value owned by the label with the Value property. is generally the attribute of a single closed tag. (value can be assigned or obtained)The innerHTML property, a double-closing label between two tags. (identification tag) (can be
In IE and Opear, DOM objects support the innerText attribute and can easily remove HTML tags.However, Firefox does not support this attribute. Fortunately, DOM objects in FF support textContent, which is equivalent to innerText.Demo instance: Hi,
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.