JavaScript Tutorial for Beginners - 39 - Create attribute

preview_player
Показать описание
In this video we will create an attribute node - this will be an ID attribute but we can add any type of attribute we want - href, class, etc.

Рекомендации по теме
Комментарии
Автор

i actually go far with this and set an id for the remove button. then i create the button with "createElement" give it id attribute and his value with "createAttribute", give it onclick also with "createAttribute" and attach by value the name of the function which responsible to hide the p and h2. then i went to hide function and include the button to be removed.

in that way, when you hit the "click if you want to read..." the h2+p+remove button appear and go aways once you click the remove button :)

you actually dont have any remove button exist in the HTML! moreover i insert the text for the button by CSS ::after element

emile
Автор

Since video 36, nothing I type out works, I'm using visual studio code even and yet nothing works

drakefransman
Автор

How come in this example when you createAttribute and assign the value of "test" (which is the darkblue color) does it only affect the p attribute and not the header above it? They are part of the same function no? and it's got nothing to do with the pAttribute because that's just the variable name?

alexe
Автор

what the difference between remove element and attribute

mmayat
Автор

for me it just wont work. I cant figure out what I am doing wrong. When i press the button it creates the new paragraph but it wont take the id and the attributes set for that id

ardeleangavril-liviu
Автор

EJ Media After I set the attribute the remove button doesn't work properly, it just remove the headers not the paragraph. Is it okay? I checked the code several time. Please show it in the next video.

arafathossen
Автор

I can't create a new paragraph, how will i remove it

<!DOCTYPE html>

<html>

<head>
<script Source\Web Site\jscode.js" charset="utf-8"></script>
<link type="text/css" rel="stylesheet" href=stylesheet.css"

</head>

<body>

<div id="main">
<h2>HANIBAL - THE BATTLE OF CANNE</h1>
<p>
After defeating the Romans at the Battle of Lake Trasimen, Hannibal now moved his forces down south. There was a panic in Rome and Quintus Fabius Maximus was appointed dictator to deal with Hannibal. Fabius, however, refused to meet ith Hannibal in the open field and this strategy became highly unpopular in Rome. Romans were used to attacking, not hifing. The Romans were forced to go on the offensive ater Hannibal positioned his forces between Rome and it's vital grain supply. This setup the epic Battle of Canne. Here Hannibal defeteated the Romans inflicting the worst single day defeat in Rome's history.
</p>
<p>
The Romans were then forced to retreat to Rome. It was a total defeat.
</p>
<h2>ATREMATH OF THE BATTLE OF CANNAE</h1>
<p>
After the horrific defeat at the Battle of Cannae, the Romans reinstituted Fabius avoidance strategy. The Romans no longer refused to meet Hannibal in head on collisions. Rather the Roman army kept a wtxhful eye on Hannibal, but always at the close distance
</p>
<p>
The avoidance strategy worked but it took forever. It took alomost two long decades to drive Hannibal out of Italy. The Roman, adopting a tactic out of Hannibal's playboo, launched an attack against Carthage itself. this forced Hannibal to trvel back to Africa to defend the city. Here he was defeteated at the Battle of Zama.
</p>

</div>
&nbsp&nbsp
<button onclick="newParagrph()">Click if you want to read about another battle </button>
<br><br>
&nbsp&nbsp
<button here to remove section</button>

</body>
</html>

jscode
function newParagraph() {

// This creates a heading
var elementH = document.createElement("h2");
var main =
main.appendChild(elementH);
var textH = document.createTextNode("The Battle of Salamis");
elementH.appendChild(textH);

// This creates a paragraph

var element = document.createElement("p");

main.appendChild(element);

var text = document.createTextNode("The Battle of Salamis was fought between an alliance of Greek cities and the Persian Empire in 480 BC. The Greeks decisively defeated the Persian navy.");

element.appendChild(text);

}

function removeHeader() {

var elementH =
var parent = elementH.parentNode;
parent.removeChild(elementH);

var elementP =
parent.removeChild(elementP);


}

ammarsadeq
Автор

what the fuck i dont understand .what the heal man ??? its auto cod ritting ??? how are understand when that heal is aoutomatik yea

Dakemake
join shbcf.ru