Stack Overflow Solution
http://stackoverflow.com/questions/34948715/set-focus-on-link-on-table-click
by HoffZ
HTML
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<div ng-app="app">
<table border="1" focus-on-link-please>
<tr>
<td><a href onfocus="focusAlert('Link A')">Link A</a></td>
<td>Some text</td>
<td>Some text</td>
</tr>
<tr>
<td><a href onfocus="focusAlert('Link B')">Link B</a></td>
<td>Some text</td>
<td>Some text</td>
</tr>
</table>
</div>
CSS
table {
width: 100%;
}
JavaScript
var app = angular.module('app', [])
app.directive('focusOnLinkPlease', function() {
return function(scope, elem, attrs) {
elem.bind('click', function(event) {
console.log('click!')
var tr = $(event.target).closest('tr') || $(event.target);
if (tr) {
tr.find('a').focus();
}
});
}
});
function focusAlert(linkX) {
console.log(linkX + ' got focus!');
}