Mouse click on <TR> of the table do not trigger the last <td>

Asked

Viewed 32 times

0

Below I have a row of a table. This row can be marked by clicking on any location of it with the mouse triggering an event click.

However, specifically on the button, I do not want the javascript event to be triggered. Because the way it is never triggers the button’s Submit, it just calls the javascript event. It is possible?

<tr role="row" class="bg-green disabled color-palette">
    <form method="POST" action="index.php"></form>
        <td class="sorting_1">26-OCT-17</td>
        <td>02:00</td>
        <td>Quinta-feira</td>
        <td>Sala 02 Bloco Cirurgico</td>
        <td class="text-center botao-td">
            <button type="submit" class="btn bg-navy btn-flat loading" id="botao-formulario"><i class="fa fa-check-square-o"></i> </button>
        </td>
    </form>
</tr>

-- Javascript:

 $("#grade-horario tr").click(function(){
     Ações.....
 }
  • Wouldn’t it be easier to activate a function called by an id and give this id to each of the 'td’s that will be able to click? Or compare the value of $(this) to the value of td that you don’t want to have the click and then only continue the code if $(this) doesn’t equal it

  • That comparison you said with the TD’s stool, how could I?

1 answer

0

Change your js code, use selectors :not and Nth-Child, do so:

$("#grade-horario tr td:not(:nth-child(5))").click(function(){
    //ações
}
  • It defaced everything. There would be no way to do some IF? like if it is clicked in the 5th column (td) does nothing, but does.

Browser other questions tagged

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