A
IE, Firefox and other browsers for the table label operation are different, in IE does not allow the table and TR innerHTML assignment, using JS to add a TR, use the Appendchile method does not use. Here are my results for three browser tests:
InsertRow
IE6: Supported, and the default parameter is-1, the default is added to the last
FireFox: Support, but the department supports default parameters
Opera: Support, support default parameters, add defaults to the top
AppendChild
IE6: Not supported
FireFox: Support, but adding TR does not affect rows
Opera: Support, Effect with insertrow (-1), Affect rows
By following the rules to the fullest, you can write safe, adaptable code:
Append a blank line to the table:
var OTR = Otable.insertrow (-1);
var otd = document.createelement ("TD");
otd.innerhtml = "";
Otd.classname = "XXXX";
Otr.appendchild (OTD);
So you can run it on these three types of browsers.
(iii) operation of ChildNodes
(1) Attribute nodename
Utils.getchildrenbytagname = function (node, tagName) {
var ln = node.childNodes.length;
var arr = [];
for (var z = 0; z < ln; z++) {
if (Node.childnodes[z].nodename = = TagName) {
Arr.push (Node.childnodes[z]);
}
}
return arr;
};
(2) Property ID
function Getnodeid (parent, id) {
var ln = parent.childNodes.length;
for (var z = 0; z < ln; z++) {
if (parent.childnodes[z].id = = ID) {
return parent.childnodes[z];
}
}
return null;
}
(3) attribute classname
Corresponding class, such as <tr class= "Class1" >
function getelementsbyclassname (node, className) {
var children = node.getelementsbytagname ("*");
var elements = new Array ();
for (var i = 0; i < children.length; i++) {
var child = Children[i];
var classnames = Child.className.split ("");
for (var j = 0; J < Classnames.length; J + +) {
if (classnames[j] = = ClassName) {
Elements.push (child);
Break
}
}
}
return elements;
}
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.