0

If one of the parameters is true then do xyz

I'm trying to get some JavaScript to run if one of the conditions is true but haven't found success yet. I've tried the following: var a = navigator.platform; if (a == "Win32" || a == "Linux armv7l" || //and so forth, you get the point...){ document.getElementById("demo").style.display = "block"; } I've also tried the switch and case code but no success. I'm trying to modify css if user has certain navigator platforms. What am I doing wrong and what should I do instead?

12th Apr 2017, 9:46 PM
Max
Max - avatar
2 Respuestas
+ 5
Try === for comparing the variable to the string¿
12th Apr 2017, 10:42 PM
Rrestoring faith
Rrestoring faith - avatar
0
可以试试 === ,==会进行类型比较
13th Apr 2017, 3:37 AM
sheng chen
sheng chen - avatar