Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

element en html and js

document.body.onload = addElement;

function addElement () {
  // crea un nuevo div
  // y añade contenido
  var newDiv = document.createElement("div");
  var newContent = document.createTextNode("Hola!¿Qué tal?");
  newDiv.appendChild(newContent); //añade texto al div creado.

  // añade el elemento creado y su contenido al DOM
  var currentDiv = document.getElementById("div1");
  document.body.insertBefore(newDiv, currentDiv);
}
Comment

element en html and js

<!DOCTYPE html>
<html>
<head>
  <title>||Trabajando con elementos||</title>
</head>
<body>
  <div id="div1">El texto superior se ha creado dinámicamente.</div>
</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: foreach loop javascript 
Javascript :: exponent in javascript 
Javascript :: unstringify json js 
Javascript :: if else alert js 
Javascript :: react native cross out letter 
Javascript :: complex json example 
Javascript :: syntax for srcset in react 
Javascript :: jshint esversion: 6 
Javascript :: get last two digits of year javascript 
Javascript :: javascript break for loop 
Javascript :: javascript wait async 
Javascript :: typeorm subquery 
Javascript :: how to collect keys using lodash javascript 
Javascript :: javascript change css 
Javascript :: set span text jquery 
Javascript :: js ternary 
Javascript :: copy one array to another javascript 
Javascript :: javascript timeout 
Javascript :: javascript array move element 
Javascript :: js to lowercase 
Javascript :: @react-google-maps/api npm 
Javascript :: push an property and value to an object in javascript 
Javascript :: reload react native app 
Javascript :: object get array of values 
Javascript :: js Float32Array to percentage 
Javascript :: jquery li count in ul 
Javascript :: unfocus javascript 
Javascript :: change px string to number 
Javascript :: slice javascript string 
Javascript :: Javascript console log a string 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =