Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda