In ajax programming, we often need to assign the page content obtained by xmlhttp to a container (such as div, span, or td) through innerHTML, but there is a problem here, that is, if the page content we will assign to innerHTML contains scripts,
The problem is trivial at times and can be ignored, but sometimes the problem is very serious and it is likely to leave our programs without the expected results. So we need to solve this problem.If you've read MSDN, you'll find that not all scripts
This problem may be insignificant or even negligible in some cases, but sometimes it is very serious, and it is likely that our program will not get the expected results. Therefore, we need to solve this problem.If you have read MSDN, you will find
Let the code inserted into the innerHTML script run during ajax programming, we often need to assign the page content obtained by xmlhttp to a container (such as p, span, or td) through innerHTML, but there is a problem here, that is, if the page
1. In JavaScript, first let's see that innerHTML and innertext can be used to get the contents of a DOM element.
We can write this:
(1) When using innertext
In JS we,
The results obtained are as follows:
(2) when using innerHTML
Run this code
InnerHTML is a strange HTML attribute, not supported by W3C standards, but almost all vendors support this attribute by default. Recently, some tests have used this attribute, here are some interesting questions about innerHTML. All elements have
When doing Ajax programming, we often need to get XMLHTTP to the content of the page through the InnerHTML to assign to a container (such as Div, span or TD, etc.), but there is a problem, is that we will be assigned to InnerHTML page content if
In ajax programming, we often need to assign the page content obtained by xmlhttp to a container (such as div, span, or td) through innerHTML, but there is a problem here, that is, if the page content we will assign to innerHTML contains scripts,
Recently, it was found that all major libraries can use xxx. innerHTMLHTML fragments to generate node elements, and then insert them into each position of the target element. This is actually insertAdjacentHTML, but the nasty innerHTML of IE turns
The InnerText property is used to define the text to be output by the object, in this case innertext the text in the object it "do you like to see a smile very much?" "Become" Super like! "(Statement it.innertext=" Super like!) ")。 The change to the
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.