Click on multiple lines

Asked

Viewed 415 times

2

I need to take all clicks of a generated html in a select.

I have the following structure:

<tr class="pesquisar" data-idlocalidade="<?php echo $linha['IDLocalidade']; ?>">
    <td class="NomeLocalidade"><?php echo $linha['NomeLocalidade']; ?></td>
    <td class="TelComercial1"><?php echo $linha['TelComercial1']; ?></td>
    <td class="Endereço"><?php echo $linha['EndLogradouro'].' - '.$linha['EndBairro']; ?></td>
    <td class="EndCidade"><?php echo $linha['EndCidade']; ?></td>
    <td class="acoes-linha">
        <div class="btn-group btn-group btn-group-justified">
            <?php if (in_array("REGRA_ADMIN_PERFIL_EMPRESAS", $_SESSION['Autoridades'])) { ?> <a href="javascript:;" class="btn btn-xs default tooltips DefinirSede <?php echo (($linha['IDLocalidade']==$EmpresaInfo->_IDSede)?'disabled':''); ?>" data-container="body" data-placement="top" data-original-title="Defninir como Localidade Sede"><i class="fa fa-map-marker"></i> </a> <?php }; ?>
            <!-- Aqui faria o envio para a pagina de edição--> <?php if (in_array("REGRA_ADMIN_PERFIL_EMPRESAS", $_SESSION['Autoridades'])) { ?> <a  class="btn btn-xs default tooltips Editar" id="EditarLocalidade" data-container="body" data-placement="top" data-original-title="Editar"><i class="fa fa-pencil-square-o"></i> </a> <?php }; ?>
        </div>
    </td>
</tr>

It returns me a normal html.

When I want to get the click of a third, fourth line, it does not identify.

$("#EditarLocalidade").click(function(){
    alert("ooi");
})

The Alert only appears in the first field, when it would have to appear in all.

Só funciona o da seta

Only the one with the arrow works.

1 answer

2


The attribute id should be unique in the form, should never be repeated. You will have to get through another selector, such as a class or an attribute any:

  $("a[data-original-title='Editar']").click(function(){
      alert("ooi");
  })
  • 1

    truth, only changed to . Edit, that was, thanks

Browser other questions tagged

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