html head doctype html meta head meta charsetutf8

  • Slides: 8
Download presentation

<html> <head> <!doctype html> <meta> <head> <meta charset="utf-8"> <title>Initiation au DOM</title> </head> <body> <h

<html> <head> <!doctype html> <meta> <head> <meta charset="utf-8"> <title>Initiation au DOM</title> </head> <body> <h 1>Le DOM</h 1> <p id="parag"> Site de la <a href="https: //www. w 3. org/"> W 3 C </a> </p> </body> </html> <body> <title> Initiation au DOM <h 1> Le DOM <p> Site de la <a> W 3 C

var head = document. head; var body = document. body; var var stuff =

var head = document. head; var body = document. body; var var stuff = document. body. child. Nodes[0]; node_h 1 = document. body. child. Nodes[1]; node_h 1_2 = body. child. Nodes[1]; parent_node_h 1 = node_h 1. parent. Node; // // #text (cas spécial) <h 1>Le DOM</h 1> <body> […] </body>

https: //www. w 3 schools. com/jsref/dom_obj_document. asp var parag = document. get. Element. By.

https: //www. w 3 schools. com/jsref/dom_obj_document. asp var parag = document. get. Element. By. Id("parag"); parag. inner. HTML; // " Site de la <a href="https: //www. w 3. org/"> W 3 C </a> parag. inner. Text; // "Site de la W 3 C" var titres = document. get. Elements. By. Tag. Name("h 1"); // [<h 1>Le DOM</h 1>] titres[0]. inner. Text = "Le nouveau DOM"; // modifiera le titre affiché "

var parag = document. get. Element. By. Id("parag"); parag. set. Attribute("style", "font-family: Calibri"); parag.

var parag = document. get. Element. By. Id("parag"); parag. set. Attribute("style", "font-family: Calibri"); parag. style. font. Family = "Calibri"; parag. set. Attribute("style");

Événement Description onchange Un élément HTML a changé onclick L’utilisateur a cliqué sur un

Événement Description onchange Un élément HTML a changé onclick L’utilisateur a cliqué sur un élément onmouseover L'utilisateur déplace le pointeur de la souris sur un élément onmouseout L'utilisateur déplace le pointeur de la souris en dehors d’un élément onkeydown L'utilisateur appuie sur une touche du clavier