Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table class="table-list">
- <tbody>
- <tr>
- <td>...</td>
- <td><a href="/link">Link</a></td>
- </tr>
- </tbody>
- </table>
- <script>
- $(function() {
- $('.table-list tr').live('click', function() {
- $('a:last', this).click();
- });
- });
- </script>
- <script>
- $(function() {
- $('.table-list tr').live('click', function() {
- $(this).off('click');
- $('a:last', this).click();
- $(this).on('click');
- });
- });
- </script>
- $(function() {
- $('.table-list').on('click', 'tr', function(){
- $(this).find('a:last').trigger('click');
- });
- $('.table-list').on('click','a',function(e){
- e.stopImmediatePropagation();
- });
- });
- <table class="table-list">
- <tbody>
- <tr style='border: 1px solid black;'>
- <td>.1.</td><td>.2.</td><td>.3.</td><td>.4.</td><td>.5.</td>
- <td class='link'><a href="/link" target="_blank">Link</a></td>
- </tr>
- <tr style='border: 1px solid black;'>
- <td>.1.</td><td>.2.</td><td>.3.</td><td>.4.</td><td>.5.</td>
- <td class='link'><a href="/link">Link2</a></td>
- </tr>
- </tbody>
- </table>
- $('.table-list td').each(function(){
- if ($(this).find('a').length === 0){
- $(this).on('click', function(){
- var link = $(this).siblings('.link').find('a');
- if (link.attr('target') === '_blank'){
- window.open(link.attr('href'));
- }
- else {
- window.location = link.attr('href')
- }
- });
- }
- });
Add Comment
Please, Sign In to add comment