DEV Community

Siddharth Kanojiya
Siddharth Kanojiya

Posted on

innerHTML, outerHTML and other properties #20

// Chapter 8 Event & Other DOM Proterties
// console.dir founction
// console.log show the element as an element iwth its properties

// tag name / node Name
// Used to read the tag of an element
// tagname --> only inisist for element node
// nodename --> defined for any node (text , comment ,etc)

// Innter HTML and Outer HTML
// The inner HTML property allow to get the HTML inside the element as a string void for the element node only ***

// The outer HTML property contains the full HTML inner HTML + the element itselft

// inner HTML is valid only for elements nodes . For other node type we can use nodevalue or data

// text content
// provide acces to the text inside the element , only txt ,minus all tags

// The Hidden Property
// The hidden attribute and the DOM property specfies wheather the element is visible or not

let x = document.getElementsByTagName('span')[0]
console.log(x)
let y = document.getElementsByTagName('span')[0]
console.dir(y)
console.log(document.body.firstChild.nodeName)
console.log(document.body.firstElementChild.nodeName)

// first.innerHTML

// first.innerHTML = "hey I am italic"

// first.outerHTML

// first.outerHTML = "

hey"

// document.body.firstChild.data

// console.log(document.body.textContent)

// first.hidden = false

Top comments (0)