JSFiddle - React, Tailwind, and code Playground

by Sandeep Nayak

HTML

<input name="text1" type="text" value="button1"/>
<input name="text2" type="text" value="button2"/>
<input name="text3" type="text" value="button3"/>

JavaScript

$(document).ready(function(){
  for(var i=1;i<3;i++){
    $("input[name='text"+i+"']").click(function(){
      alert(i);

    });
  }

});