JSFiddle - React, Tailwind, and code Playground

by raskalbass

HTML

<p></p>
<a href="#">click</a>

JavaScript

function add(cou) {
    $("p").text("");
    if (cou > 0) {
        while (cou > 0) {
            $("p").text($("p").text() + " next");
            cou--;
        }
    }
    if (cou < 0) {
        while (cou < 0) {
            $("p").text($("p").text() + " prev");
            cou--;
        }
    }
}

$("a").click(function () {
    add(-2);
});