There are several ways to do this.
What you will currently be working with a little modification:
var rownum;
$('#myTable').find('tr').click( function(){
rownum=$(this).index()
alert('You clicked row '+ (rownum) );
});
Hovever, the preferred method would be to pass the variable where it was needed:
function alertRowNumber(rowNumber) {
alert('You clicked row '+ (rowNumber) );
}
$('#myTable').find('tr').click( function(){
alertRowNumber($(this).index)
});
, .