45 lines
1.3 KiB
HTML
45 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<p class="azonosito">1</p>
|
|
<p class="azonosito">2</p>
|
|
<p name="nev">asd</p>
|
|
<p name="nev">asd</p>
|
|
<p id="asd"></p>
|
|
|
|
<script>
|
|
let elem = document.querySelectorAll("[name='nev']");
|
|
console.log(elem);
|
|
let elem2 = document.querySelector("#asd");
|
|
elem2.textContent = "textcontent<br>";
|
|
console.log(elem2);
|
|
let elem3 = document.querySelectorAll(".azonosito");
|
|
elem3[1].innerHTML = "asd";
|
|
console.log(elem3);
|
|
elem3[0].style.backgroundColor = "yellow";
|
|
|
|
elem2.setAttribute("title", "cim");
|
|
console.log(elem2.getAttribute("title"));
|
|
elem2.removeAttribute("title");
|
|
console.log(elem2.getAttribute("title"));
|
|
|
|
let ujelem = document.createElement("div");
|
|
ujelem.innerHTML = "Új elem tartalma";
|
|
//document.body.appendChild(ujelem);
|
|
|
|
let nagyszulo = document.getElementById("asd");
|
|
let szulo = document.createElement("div");
|
|
szulo.innerHTML = "Szülő";
|
|
nagyszulo.appendChild(szulo);
|
|
|
|
szulo.appendChild(ujelem);
|
|
|
|
nagyszulo.removeChild(szulo);
|
|
</script>
|
|
</body>
|
|
</html> |