Could you tell me how to turn on the timer and turn it off automatically after 3 seconds?

I want to click button a to start the timer and turn it off after 3 seconds

    function tablar(){
        setInterval(function() {
            document.getElementById("tabla").play();
        }, 100);
    };
    $(".a").click(function(){
        tablar();
        clearInterval(tablar,3000);
    });
Apr.22,2022


d1.onclick = function () {

    var timer = setInterval(function() {
        console.log(123)
    }, 100);

    setTimeout(function () {
        clearInterval(timer)
        timer = null
    },3000)
}
Menu