Regarding the knowledge learned from it:
document.getelementbyid("ddhdh").innerHTML can get all the data in the div, including tags. . . But just using
document.getelementbyid("ddhdh").innerTEXT in IE and OPERA can get the text data in the div, but not the tag. . . But just use
document.getElementById(“text”).textContent in IE and OPERA to get data in Firefox
The above tag is based on the two browsers these days. For kernel browsers, these methods are incompatible.
The following is the solution
JS compatible with Firefox IE to get the content of the div
if(navigator.appName.indexOf("Explorer") > -1)
var text = document.getElementById(“text”).innerText;
else
var text = document.getElementById(“text”).textContent;
is used to get The name of the browser, the first sentence means that the name of the obtained browser contains Explorer.
Involves indexof usage
strObj.indexOf(subString[, startIndex])
Parameters
strObj
Required. String object or literal.
subString
Required. The substring to find in the String object.
starIndex
Optional. This integer value indicates the index within the String object at which to begin the search. If omitted, the search is from the beginning of the string.
The indexOf method returns an integer value indicating the starting position of the substring within the String object. If the substring is not found, -1 is returned.