JSFiddle - React, Tailwind, and code Playground
by gion_13
HTML
<a href="a/3/b/5">a=>3 b=>5</a>
<a href="a/13/b/25">a=>13 b=>25</a>
<a href="a/-3/b/2">a=>-3 b=>2</a>
CSS
a{
display : block;
}
JavaScript
// toate elementele 'a' care au attributul 'href' setat
$('a[href]').click(function(e){
var params = $(this).attr('href').split(/\//g);
if(params.length < 4)
{
console.log(' nu sunt 4 parametri => nu facem nimic');
return;
}
var a = params[0],
b = params[2],
a_val = params[1],
b_val = params[3];
console.log(a + ' / ' + a_val + ' / ' + b + ' / ' + b_val);
//cancel the event so that the page doesn't go to the a's href
e.preventDefault();
});