JSFiddle - React, Tailwind, and code Playground

by vendruscolo

HTML

<div id="pagination">

<a rel="prev" href="uno.html" title="indietro">Previous</a>
-
<a href="/" title="home">Home</a>
-
<a rel="next" href="due.html" title="avanti">Next</a> 

</div>

JavaScript

$(document).keydown(function(e) {
    var url = false;
    if (e.which == 37) {  // Left arrow key code
        url = $('a[rel="prev"]').attr('href');
    }
    else if (e.which == 39) {  // Right arrow key code
        url = $('a[rel="next"]').attr('href');
    }
    if (url) {
       alert(url);
       //window.location = url;
    }
});