const links = document.querySelectorAll('.navigation__link');
links.forEach(link => {
const btn = document.createElement('button');
btn.textContent = "BUTTON";
link.appendChild(btn);
});
4.5.1. The a element
Content model:
Transparent, but there must be no interactive content or a element descendants.
Interactive content is content that is specifically intended for user interaction.
a (if the href attribute is present), audio (if the controls attribute is present), button, details embed, iframe, img (if the usemap attribute is present), input (if the type attribute is not in the Hidden state), label, select, textarea, video (if the controls attribute is present).
The tabindex attribute can also make any element into interactive content.
if (typeof isNumber == 'number') {
return true;
} else {
return false;
}
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$dirname = trim($_POST['dir'] ?? '');
if ($dirname && mkdir($dirname)) {
echo "Директория создана";
} else {
echo "Не удалось создать директорию";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="index.php" method="post">
<input type="text" name="dir">
<input type="submit">
</form>
</body>
</html>
function getFiles($path,$lvl = 0){
$res = [];
$dir2 = scandir($path);
foreach($dir2 as $file2){
if (($file2!='.') && ($file2!='..')){
$fullpath = $path . DIRECTORY_SEPARATOR . $file2;
if(is_dir($fullpath)){
$res = array_merge($res,getFiles($fullpath,$lvl+1));
array_push($res,["path"=>$fullpath,"name"=>$file2,"type"=>"DIR","level"=>$lvl,"size"=>filesize($fullpath)]);
}else if(is_file($fullpath))
array_push($res,[ "path"=>$fullpath,"name"=>$file2,"type"=>"FILE","level"=>$lvl,"size"=>filesize($fullpath)]);
}
}
return $lvl == 0 ? array_reverse($res): $res;
}
function showFiles($arr){
foreach($arr as $v){
$margin = $v["level"] * 15;
if($v["type"] == "DIR")
echo "<span style='display:block;font-weight:bold;margin-left:{$margin}px;'>$v[name]</span>";
if($v["type"] == "FILE")
echo "<a style='margin-left:{$margin}px;display:block;' href='$v[path]'>$v[name] ($v[size] байт)</a>";
}
}
showFiles(getFiles('yourdir'));