This example shares the specific code for JS to implement the random naming function for your reference. The specific content is as follows
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div ></div> <button >stop</button> </body> <script type="text/javascript"> var flag = true; var str = "Zhang San, Li Si, Wang Wu, Ma Liu"; var arr = (","); var interId = setInterval("randName()",100); function randName(){ var rand = (() * ); = arr[rand]; } = function (){ if (flag) { = "start"; clearInterval(interId); flag = false; } else{ = "stop"; interId = setInterval("randName()",100); flag = true; } } </script> </html>
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.