Table With Input type Upload File only one line listens to the event

Asked

Viewed 52 times

0

Hello, gentlemen I have a table where in it has a column that has an input type file, when pressing the input only the first line listen to the event, you would know me to tell what I am doing wrong?

$("#uploadBtn").on('change', function(e) {
  
  });
<table class="table table-condensed" id="tblformacao">
<tr>

  <td> 
  <input id="uploadBtn" type="file" class="upload" onchange="UploadFile(this)" name="Anexar   Documento" />
  
  </td>
  
</tr>

  • 1

    I believe it is due to the fact that this selected by ID, try to select a class: $(".upload").on('change', function(e) { ... }), if necessary, add an additional class for this purpose.

  • 1

    @Tobymosque worked thanks.

1 answer

0


If I understand your question, I believe the problem happens because ID’s should be used only once inside the document.

You can select the input elements this way:

$('input[type=file]')

Also remembering that you can define which files are accepted by your input type using the Accept attribute, this way:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.