Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished attempt 1 #1473

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,107 @@

import './less/index.less'

// Your code goes here!

// Selecting Elements to change
const navButtons = document.querySelectorAll(".nav a");
console.log(navButtons);
const title = document.querySelector("h1");
const introImg = document.querySelector(".intro img");

// Creating Events with .addEventListener

// function greyBackground() {
// EventTarget.style.color = 'grey'
// }

// navButtons.addEventListener("mouseover", greyBackground);

navButtons.forEach(element => {
element.addEventListener('mouseover', (event) => {
event.target.style.backgroundColor = 'lightgrey';}
)});

// click - 1
title.addEventListener('click', event => {
title.textContent += ` Is Taking Off!!`;
})

// dblclick - 2
introImg.addEventListener('dblclick', function (event){
introImg.style.border = '5rem';
})

//load on my own - 3
window.addEventListener('load', (event) => {
console.log('Good job loading');
});

// keydown - 4
window.addEventListener('keydown', evt => {
if (evt.key == 6){
document.body.innerHTML = '<h1>Sent to File 13<h1>'
}
})

// Load
window.onload = function (evt) {
const heading = document.querySelector('h1')
heading.textContent = 'READY TO GO'

// Copy - 5
window.addEventListener('copy', () => {
navigator.clipboard.readText()
.then(text => {
heading.textContent += text
})
})

document.body.addEventListener('click', evt => {
evt.target.classList.toggle('mirror')
})

// mousemove - 6

document.body.addEventListener('mousemove', evt => {
const {clientX, clientY} = evt
console.log(`mouse is at ${clientX}, ${clientY}`)
})

// mouseenter - 7

// mouseleave - 8

const destinations = document.querySelectorAll('.destination')
for (let destination of destinations) {
destination.addEventListener('mouseenter', () => {
destination.style.fontWeight = 'bold'
})
destination.addEventListener('mouseleave', () => {
destination.style.fontWeight = 'initial'
})
}


}


// Prevent Default - 9

Array.from(document.links).forEach(link => {
link.addEventListener("click", function(evt) {
evt.preventDefault();
console.log(`The ${evt.target.textContent} link doesn't work, but I'm sure glad you came.`)
})
})


// scroll - 10
let last_known_scroll_position = 0;
window.addEventListener('scroll', function(event) {
last_known_scroll_position = window.scrollY;
console.log(last_known_scroll_position)
if (last_known_scroll_position >= 950){
alert("That's All Folks")
}
});