Home > Web Front-end > HTML Tutorial > innerHTML在IE与FF、chrome、opera浏览下获取的HTML标称名大小写不一样_html/css_WEB-ITnose

innerHTML在IE与FF、chrome、opera浏览下获取的HTML标称名大小写不一样_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-24 11:23:49
Original
980 people have browsed it

今天在获取select中的option元素,然后通过正则表达式把option字符转换成li字符时,在chrome FF opera中能成功,在IE下还是option字符.

用alert()弹出框打印出来一看,打印出来的HTML元素标签名都是大写的。


原来是这么写的:

optionsUI = optionsUI.replace(/(option)/g,"li");
Copy after login


修改后这么写的:

optionsUI = optionsUI.replace(/(option)/gi,"li");
Copy after login

开始没有考虑到在IE下获取的HTML标签名是大写的。所以没有加在 i 。


附上一张有关regexp修饰符



IE效果标签名是大写:



chrome效果标签名是小写的:



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template