When someone double clicks on the entire row, I want an alert. How do I bind a double click to an entire row?
+2
A:
...
$('#table_id tr').dblclick(function(){
alert('Hello');
});
Note: Using JQuery here, see more info about dblclick here.
Sarfraz
2010-04-13 19:00:38
@Alex - Please note that you must download/link to the jQuery framework for this function to work. @Sarfraz - he didn't mention jQuery in his tags, was not sure if he would recognize the syntax.
Tommy
2010-04-13 19:02:08
awesome, thanks.
TIMEX
2010-04-13 23:40:29
+2
A:
Well, without jQuery I suppose you could do something like this:
var rows = document.getElementsByTagName('tr'); // you do mean table rows, right?
var length = rows.length;
for (var i = 0; i < length; i++) {
rows[i].ondblclick = function(){alert('foo');};
}
Bob
2010-04-13 20:55:33