Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

226
Visualizações
jquery getting data from data-href

I am trying to make a table row a link by using jQuery and this:

jQuery(document).ready(function() {
    $(".clickable-row").click(function() {
        window.location.href = $(this).data('href');
    });
});

In my html file i have this:

<tr class='clickable-row' data-href='my-page.com/user/123'>
    <td><span class="glyphicon glyphicon-user"></span></td>
    <td>{{ member.getFornamn }} {{ member.getEfternamn }}</td>
    <td>{{ member.getEmail }}</td>
    <td>{{ member.getTel1 }}</td>
    <td>{{ member.getPostadress }}</td>
    <td>{{ member.getPostnr }}</td>
</tr>

Nothing is happening. If i change to this: window.location.href = 'www.google.com'; it's working so I know WERE the problem is...

What am I missing?

Edit: Plunker: http://plnkr.co/edit/0MBucaxR1fDpYZjZRLHc?p=preview

For some reason above doesn't work for me. If I use this it works:

jQuery(document).ready(function() {
    $(".clickable-row").click(function() {
        window.location.href = '**any link at all**';
    });
});

But when i change to this my console log don't even recognize my click...??

jQuery(document).ready(function() {
    $(".clickable-row").click(function() {
        window.location.href = $(this).data('href');
    });
});
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I did this:

jQuery(document).ready(function() {
    $(".clickable-row").click(function() {

        thisdata = $(this).attr('data-href');
        console.log(thisdata);

        window.location.href = thisdata;
    });
});

And the console gave me the correct answer.

I noticed that my actual table looked like this:

<tr class='clickable-row' data-href='URL://my-page.com/user/123'>

So by removing the URL:// it works now.

Thand you for your help!

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda