Button not triggering function in JavaScript

0

The close button works fine while the submit button does not trigger the routine at all.

$("#incluirItensNoGrid").on('click', function(){
  alert("Hello World!");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="modal-footer d-flex justify-content-center">
  <button 
    class="btn btn-success" 
    id="incluirItensNoGrid()">Enviar
  </button>
  <button 
    class="btn btn-danger" 
    class="close" 
    data-dismiss="modal" 
    aria-label="Close">Cancelar
  </button>
</div>
    
asked by anonymous 15.06.2018 / 22:37

1 answer

1

The button id, change to id="incluirItensNoGrid" by removing () at the end because you are setting the ID property and not calling a function ...

Getting:

<div class="modal-footer d-flex justify-content-center">
<button 
    class="btn btn-success" 
    id="incluirItensNoGrid">Enviar
</button>
<button 
    class="btn btn-danger" 
    class="close" 
    data-dismiss="modal" 
    aria-label="Close">Cancelar
</button>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.min.js"integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>

<script type="text/javascript">
$("#incluirItensNoGrid").on('click', function(){
    alert("Hello World!");
});
</script>
    
15.06.2018 / 22:38