Home > Blockchain >  How to get the name of input filed in jquery
How to get the name of input filed in jquery

Time:07-06

I have a multiple-input field and an onchange function. When we change the input field from the event it triggered, I want to get the name or id of the input field (to distinguish it from other input fields). Many thanks.

CodePudding user response:

$('input[type="text"]').on('change', function(){
      // name is a unique attribute
      $(this).attr("name"));
});

<input type="text" name="text1" />
<input type="text" name="text2" />
<input type="text" name="text3" />
  • Related