javascript dom manipulation
var newDiv = document.createElement('div');
newDiv.innerHTML = '<p>Hello World!</p>';
document.body.appendChild(newDiv);<!-- USING EVENT HANDLER FOR DOM HTML -->
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>WEB222</title>
<style>
body { margin: 0 18%; }
</style>
<script>
window.onload = function() { // why use window.onload?
var elem = document.querySelector("#myBtn");
elem.addEventListener( "click", displayDate );
}
function displayDate() {
document.querySelector("#demo").innerHTML = (new Date()).toLocaleString();
}
</script>
</head>
<body>
<h1>WEB222 - HTML DOM Event</h1>
<p>Click "Show Current Time" to execute the displayDate() function.</p>
<p id="demo"></p>
<button id="myBtn">Show Current Time</button>
<br>
<!-- for downloading source files -->
<p><a href="" Download>Download</a></p>
</body>
</html>
Also in JavaScript:
- fetch data from external url nodejs
- jquery checkbox
- merge two objects javascript
- use callback vs use memo
- jquery detect textarea change
- string repeat
- jquery on scroll x pixels
- javascript in html einbinden
- js array map skip element
- how to use json file in nodejs
- jquery wait for element to exist
- Error: Not implemented: window.alert
- how to access data in firebase realtime
- how to change drawing tool color google map
- pdfjs get all the text present
- iterate over array javascript
- how to filter array objesct in express node js
- javascript add 1 to each element in array
- react big calendar messages
- javascript fill array
- urlencoded json express
- ajax send multiple data to php
- document.addEventListener("backbutton
- TypeError: expect(...).toMatchSnapShot is not a function