Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

225
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!