1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="Description" content = "">
<title>Baromètre Social</title>
</head>
<body>
<h1 id="titre">Sans titre</h1>
<p onclick="addInput(this,'insert_input')">Cliquer ici pour insérer un champ</p>
<div id="insert_input"></div>
<p onclick="changeTitle('toto')">Cliquer ici pour changer le titre avec toto</p>
<script>
function addInput(element,id_cible)
{
var input = '<input type="text" /><button onclick="changeTitle(this.previousSibling.value);">Changer le titre avec le contenu de l\'input text ci-contre</button>';
document.getElementById(id_cible).innerHTML = input;
element.remove();
}
function changeTitle(value)
{
document.getElementById("titre").innerHTML = value;
}
</script>
</body>
</html> |