Home  >  Article  >  Web Front-end  >  Example introduction to the difference between jquery getting color under ie and ff_jquery

Example introduction to the difference between jquery getting color under ie and ff_jquery

WBOY
WBOYOriginal
2016-05-16 16:54:111121browse

When using $("#id").attr("color") to get the color, ie and ff are different. Take a simple example:

Copy code The code is as follows:



Use $("#id").attr("color") to get the value "green" in ff and chrome, and in ie The value obtained is "#008000".

So, if you use attr("color") to determine the current color, considering compatibility, you need to determine the color name and the corresponding color code at the same time. For example:
Copy code The code is as follows:

if($("#id"). attr("color") == "green" || $("#id").attr("color") == "#008000" ){
alert("this color is green!!");
}
Statement:
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