JSFiddle - React, Tailwind, and code Playground

by Dongor7

HTML

<div id="section">
  <button data-offer="a">
    Click A
  </button>
  <button data-offer="b">
    Click B
  </button>
</div>
<div id="modal">
  
</div>

JavaScript

var offers = {
  a: {
    title: 'Aaa',
    services: [
      {
        name: 'first',
        cost: '100'
      },
      {
        name: 'second',
        cost: '200'
      }
    ],
  }
}

var section = document.getElementById('section')
section.addEventListener('click', function(event) {
  console.log(event.target)
  //console.log(event)
  if (event.target.dataset.offer) {
  	alert(dataOffer)
  }
})