JSFiddle - React, Tailwind, and code Playground

by divad12

HTML

<nav>
 <div>item #1</div>
 <div>item #2</div>
 <div>item #3</div>
</nav>

CSS

nav div:nth-child(1) { background: red; }
nav div:nth-child(2) { background: blue; }
nav div:nth-child(3) { background: yellow; }

JavaScript

$(function() {

      $('nav div').click(function() {
          console.log($(this).index() + 1);
      });

  });