I have labels with for="#input_id" tag as illustrated below. However, multiple labels trigger the same input field (with id) to attach a user selected file. I want to now which label triggered the input field.
<label id="label1" for="input1">Document1</label>
<label id="label2" for="input1">Document2</label>
<label id="label3" for="input1">Document3</label>
<label id="label4" for="input1">Document4</label>
<input type="file" id="input1" accept="application/pdf" />
$("#input1").change(function() {
//some js for checking file type and file size etc
//looking for some code to findout which label clicked to trigger file input
});
When i click labels it triggers input field however i need to know which label clicked to save file path to suitable div by using data-fpath="some path".
I use jquery however any javascript solution is OK for me.