JSFiddle - React, Tailwind, and code Playground

HTML

<div class="xxx" onClick="replaceClass(this)"><img src="http://mywishlist.ru/pic/i/wish/orig/006/372/981.jpeg"></div>

CSS

.xxx img {
opacity:.05
      }
      .xxx:before {
        opacity;1;
position: absolute;
margin: 0;
    padding: 0;
    content: "не смотреть, если нет 18 лет";
    font-size:30px;
    color:red;
    top: 20%;
    left: 20%;
    display: block;
        }
        .yyy:before {
        }

JavaScript

replaceClass =function (elem) {
console.log(elem)
	if (elem.className === 'xxx') {
		elem.className = 'yyy';  
  } else {
  elem.className = 'xxx';
  }
  }