How do you detect devices on HTML?

I want a simple HTML script to detect device plug in or color changing . Like this below.

How do I do this?

Reading the docs obviously never hurts.
Check if there’s something web-related. Lo and behold “particleJS”. If you scroll through that a bit you’ll find the “device management” section. In there is an example on how to get the status of a device. Then you take that example and do whatever you like with it.
If you check the examples at the bottom, you’ll find some for Node.JS, which are easily adapted since it’s just JavaScript.
You can also take a look at my page to see how I did it.
Alternatively, use the Cloud API section of the docs, and make your own REST calls. Whatever floats your boat.