How to compare CSS with a String in JS? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to compare CSS with a String in JS?

Why does »document.getElementById(…).style.left=="5px"« return false if CSS is »left:5px;«?

19th Dec 2018, 4:34 PM
C. Scheler
C. Scheler - avatar
1 Answer
+ 2
Defining in CSS won't let you get true in logical comparison in JS. It returns true if you use js to assign it first.
19th Dec 2018, 5:29 PM
Gordon
Gordon - avatar