Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This solution has integrated page switching in it. </p> <pre><code>var $rows = $('.myrow'), $cells = $('.mycell'); $(document).keydown(function (e) { var arrowKeys = [37, 38, 39, 40]; var directions = ['left', 'up', 'right', 'down']; var arrowIndex = $.inArray(e.which, arrowKeys); if (arrowIndex !== -1) { var dir = directions[arrowIndex]; var $currCell = $cells.filter('.selected').removeClass('selected'); var cellIndex = $currCell.index(); var $currRow = $currCell.parent(); if (dir == 'up' || dir == 'down') { switchRows($currRow, dir, cellIndex); } else { var $nextCell; if( dir=='left'){ $nextCell= $currCell.prev().addClass('selected'); if( !$nextCell.length){ switchRows($currRow, 'up', 150000); } }else{ $nextCell= $currCell.next().addClass('selected'); if( !$nextCell.length){ switchRows($currRow, 'down',0); } } } e.preventDefault(); // prevent the default action (scroll / move caret) } }); /* switches rows and toggles page visibility if next image on another page going up or down*/ function switchRows ($currRow, direction, cellIndex) { var $next, curRowIndex = $rows.index( $currRow); if (direction == 'up') { $next = $rows.eq(curRowIndex-1) $next = $next.length ? $next : $rows.last(); } else { $next = $rows.eq(curRowIndex+1) $next = $next.length ? $next : $rows.first(); } var $nextCell= $next.find('.mycell').eq(cellIndex); if( !$nextCell.length){ $nextCell= $next.find('.mycell').last(); } $nextCell.addClass('selected'); $currRow.parent().hide(); $next.parent().show(); /* add button class change logic */ } </code></pre> <p><kbd><strong><a href="http://jsfiddle.net/m3MK3/13/" rel="nofollow">DEMO</a></strong></kbd></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload