您好,欢迎访问一九零五行业门户网

JS 动态获取节点代码innerHTML分析 [IE,FF]_javascript技巧

child
当为子节点添加默认属性时:
childnode.classname = childclass; 或: childnode.classname = new string(childclass);
parentnode.innerhtml ie,ff都能获得 [ child ]
当为子节点添加私有属性时:
childnode.type = childtype;
parentnode.innerhtml 当且仅当 ie能获得 [ child ]
childnode.type = new string(childtype); //object对象
parentnode.innerhtml ie,ff都不能获得 [ child ]
childnode.setattribute(type,childtype);
parentnode.innerhtml ie,ff都能获得 [ child ]
childnode.setattribute(type, new string(childtype));
parentnode.innerhtml 当且仅当 ff能获得 [ child ]
当对元素动态添加私有属性后获取innerhtml,如果采用.属性 方式赋值,无论哪种数据类型firefox都不能获得,如果当赋值的类型是个对象的话ie不能通过innerhtml获得。
如果使用setattribute方法赋值时,无论哪种数据类型firefox都能获取,如果当赋值的类型是个对象的话ie不能获取 。
总结:在ie 环境下 赋值类型为对象时 innerhtml 获取不到其改变,在firefox环境下 .属性 方式获取不到其改变。
其它类似信息

推荐信息