I recently encountered an issue with my Javascript method that checks for bold font-weight on an element.
function selected(element) {
return element.css("font-weight") === "bold";
}
Although the code used to work perfectly fine, it suddenly stopped working.
Upon inspecting the element, I noticed that its CSS remained unchanged:
<td title="Example" style="font-weight: bold; color: black;">EXAMPLE</td>
Surprisingly, the function now returns false.
This is because element.css("font-weight")
now returns a number (700).
To fix this issue, I updated my function to:
function selected(element) {
return element.css("font-weight") === "bold" || element.css("font-weight") === "700";
}
After making this change, it started working again. Can anyone explain why this was necessary? Could it be related to using Chrome 62.0.3202.94?