Javascript Opacity

I’m trying to do something as simple as making a text or a colored box opaque on click using javascript. Some thing simple to see how exactly it works to do so. I tried doing it using a loop but had no success.

I was wondering if you guys could show me an example and maybe help me understand how it works exactly?

This should help you out CSS Opacity: A Comprehensive Reference