DEV Community

Discussion on: Displaying a css spinner on ajax calls with fetch api

Collapse
 
moopet profile image
Ben Sinclair

This is largely irrelevant to your post :), but you can replace

  spinner.className = "show";
  // ...
  spinner.className = spinner.className.replace("show", "");
Enter fullscreen mode Exit fullscreen mode

with

  spinner.classList.add('show');
  // ...
  spinner.classList.remove('show');

Enter fullscreen mode Exit fullscreen mode

which I think makes things a little easier to read and won't interfere with any existing classes.

Collapse
 
wangonya profile image
Kelvin Wangonya

Very nice. Didn't know about that 😀