i need to check style.width with an js if statement. But it is not working. How can i do that?
My if code:
if (document.getElementById("XXX").style.width == "100%")
{
}
i need to check style.width with an js if statement. But it is not working. How can i do that?
My if code:
if (document.getElementById("XXX").style.width == "100%")
{
}
 
    
    As the "width" style could actually be empty (not be there), I would personally check that too.
var elm_width = document.getElementById("XXX").style.width;
if(elm_width && elm_width == "100%"){
  ...
}
or even, depending on the script flow...
var elm_width = document.getElementById("XXX").style.width;
if(elm_width){
  if(elm_width == "100%"){
    ...
  }
}else{
  console.error('No width for element');
}
NOTE: Of course, this is if you need the actual CSS width. If you want to get the visual element width, as suggested before, there are other JS methods.
