Finding Elements
- Find elements using document.querySelector () function
create
div.insertAdjacentHTML('beforeend', '<h1>gua</h1>')
删除
let pwd = document.querySelector('#id-input-password')
pwd.remove()
event
Event is used to process a response mechanism
1. Get the button
loginButton = document.querySelector('#id-button-login')
2. Declare a function to be executed after clicking the button
C const
licked = function () {
log ( 'button is clicked to')
}
// 3. Add an event using addEventListener function, it has two parameters
// The first is the name of the event, the second is the function will be automatically called after the incident, called the callback function
loginButton.addEventListener ( 'click ', clicked)