Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

In Class W2 #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
43 changes: 35 additions & 8 deletions Week-2/InClass/A-dom-manipulation/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,63 @@ Write JavaScript below that logs:
--> should log a list of nodes with a length of 3

*/

console.log(document.querySelectorAll("p"));
console.log(document.querySelector("div"));
console.log(document.querySelectorAll("#jumbotron-text"));
console.log(document.querySelectorAll(".primary-content p"));

/*
Task 2
======

When a user clicks the 'ALERT' button, an alert box should pop up with the text "Thanks for visiting Bikes for Refugees!"
*/


let clickButton = document.getElementById("alertBtn");
clickButton.addEventListener("click", alertSomething);
function alertSomething() {
alert("Thanks, Domenico for visiting Bikes for Refugees!");
}
/*
Task 3
=======

Write JavaScript below that changes the background colour of the page when the 'Change colour' button is clicked.
*/


let clickBackgroundButton = document.getElementById("bgrChangeBtn");
function changeBackground() {
document.body.style.backgroundColor = "blue";
}
clickBackgroundButton.addEventListener("click", changeBackground);
/*
Task 4
======

When a user clicks the 'Add some text' button, a new paragraph should be added below the buttons that says "Read more below."
*/
let clickThatButton = document.getElementById("addTextBtn");


clickThatButton.addEventListener("click", addNewPar);
function addNewPar() {
let paragraph = document.createElement("p");
paragraph.innerText = "Read more below.";
let myElement = document.querySelector(".buttons");
myElement.appendChild(paragraph);
};

/*
Task 5
======

When the 'Larger links!' button is clicked, the text of all links on the page should increase.
*/
*/
let largerLinkButton = document.querySelector("#largerLinksBtn");
console.log(largerLinkButton);
largerLinkButton.addEventListener("click", makeLinksLarger);

let allLinks = document.querySelectorAll("a");
function makeLinksLarger() {
console.log(allLinks)
for( let i = 0 ; i < allLinks.length; i++) {
console.log(allLinks);
allLinks[i].style.fontSize = "50px";
}
}
8 changes: 7 additions & 1 deletion Week-3/InClass/DOM-practice/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ console.log("Testing JS file loaded!")
// Without changing any of the HTML or CSS, update the <section> tags so that they have white backgrounds.


function sum(a,b){

return a + b;

}

console.log(sum(12,1));


let sum2 = (a,b) => a+b;
console.log(sum2(2,3))
// Task 2

// Without changing any of the HTML or CSS, update the images on the page so that they are all centered.
Expand Down