<html>
<head>
<title>example</title>
</head>
<body>
<input type="text" id="input-1"><br>
<input type="text" id="input-2"><br>
<input type="text" id="input-3"><br>
<input type="text" id="input-4"><br>
<input type="text" id="input-5"><br>
<input type="text" id="input-6"><br>
<script>
var event_click = function ()
{
console.log(this.getAttribute('id').split('-')[1]);
}
Array.prototype.forEach.call(document.querySelectorAll('input[type=text]'), function (ths)
{
ths.onclick = event_click;
});
</script>
</body>
</html>