Leo Pamungkas Nasution Leo Pamungkas Nasution - 6 months ago 10
Javascript Question

how to random function to the function



so here my problem i wanna when i want to click some div.


i have function that name arti1(),arti2(),arti3().
so if i click that div.the function on that div like this

<div class="random" onclick="rondom()">Random</div></div>


function rondom(){

var rndm = Math.floor(Math.random() * 8) + 1;
arti+rndm+().css("display", "block");
}






how to display that random function? can anybody answer my question

Answer

<div class="random" onclick="rondom()">Random</div></div>

function rondom(){

    var rndm = Math.floor(Math.random() * 8) + 1;
    eval("arti"+rndm+"().css(\"display\", \"block\")");
    }

Now it works!