Skip to content Skip to sidebar Skip to footer

Open Link When Doubleclicking On Table Row With Jquery

I have a table that looks like this:

Solution 1:

Do you have any jQuery you've written yet? Here's a headstart...

Define your ID in the row:

<trid="something">...</tr>

Then use something like this:

$('tr').dblclick(function(){
  var id = $(this).attr('id');
  //do something with id
})

Solution 2:

Do you mean something like this:

$(document).ready(function() {
    $('.tablecell').click(function() {
        returnfalse;
    }).dblclick(function() {
        window.open("your_url");
        returnfalse;
    });
});

and you could create a hidden field and populate that field with the id when double clicked.

Solution 3:

Working demo:http://jsfiddle.net/Xr7LC/ (created from the sample code you provided)

  1. Use dblclick api http://api.jquery.com/dblclick/

  2. You can use $(this).attr('id') to get the id, and obviously you will define the id in a tag.

jQuery code for dblclick:

$(document).ready(function() {
    $('#table >thead > tr').dblclick(function() {
    alert('Row dblclicked');
        alert($(this).attr('class'));
    });
});​

Solution 4:

This may help you:

jQuery(function($) {
    $('#table tr').click(function() {
        returnfalse;
    }).dblclick(function() {
        window.location = url;
        returnfalse;
    });
});

Post a Comment for "Open Link When Doubleclicking On Table Row With Jquery"

Test