JSFiddle - React, Tailwind, and code Playground

by Nikhil krishnan

HTML

<div class="box" style="background-color: #2980b9">
    <button>
    show bg color code
    </button>
    <p></p>
</div>

CSS

.box{
  width: 300px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

button{
  border: none;
  background-color: #fff;
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 5px 5px rgba(0,0,0,0.2);
}
p{
  color: white;
}

JavaScript

$('button').click(function(){
	$('p').html('The color code is = ' + $(this).parent().css('background-color'))
})