I have some php code to echo a list of files in a directory. It works fine, but then I need to use Javascript to hide them after 5 seconds, but for some reason the script doesn't work. Do you know what I need to fix?
$dir = "/var/www/files/";
$list = preg_grep('/^([^.])/', scandir($dir));
foreach (preg_grep('/^([^.])/', scandir($dir)) as $list)
echo "<span class='list' style='color:red'>$list</span>"."<br>";
echo "<script>
setTimeout(function () {
document.getElementsByClassName('list').style.display='none';}, 5000);
</script>";