JSFiddle - React, Tailwind, and code Playground
by musefan
HTML
<div class="container">
<a href="#mylink" tabindex="-1">select this</a>
<a href="#mylink" tabindex="-1">select this</a>
<a href="#mylink" tabindex="-1">select this</a>
</div>
<a href="#begin" tabindex="-1">click here to begin selecting</a>
JavaScript
var beginWasLast = false;
$('a[href="#begin"]').blur(function(e) {
e.preventDefault();
beginWasLast = true;
console.log( e.target.href ); // this will output: #begin
});
$('a[href="#begin"]').click(function(e) {
e.preventDefault();
});
$('a:not(a[href="#begin"])').blur(function(e) {
e.preventDefault();
beginWasLast = false;
});
$('a:not(a[href="#begin"])').click(function(e) {
e.preventDefault();
if(beginWasLast){
console.log( e.target.href );
}
});