Created
August 13, 2019 19:40
-
-
Save NimaBoscarino/bff66136c523584f15a59f232d44b04f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Heyo what up!</h1> | |
<h2>Heyo what up!</h2> | |
<h3>Heyo what up!</h3> | |
<h4>Heyo what up!</h4> | |
<script src="script1.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setTimeout(() => { | |
// const h1 = document.querySelector('h1') | |
// h1.innerText = 'Blah bah laskdgaskdj' | |
// alert('woooo') | |
// }, 2000) | |
/* | |
When someone clicks on the page then change the text | |
*/ | |
const h3 = document.querySelector('h3') | |
h3.onclick = () => { | |
// alert('hello!') | |
h3.style.color = 'red' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(() => { | |
// a button that generates random cat pictures | |
// when you click the button | |
// print out a message | |
$('#catButton').on('click', () => { | |
const newImage = $(`<img>`) | |
const height = getRandomInt(150) | |
const width = getRandomInt(150) | |
newImage.attr('src', `https://placekitten.com/${height}/${width}`) | |
$('body').append(newImage) | |
}) | |
// another button to roll a D20 die | |
// when you click on the button for the d20 | |
$('.d20 button').click(function () { | |
//choose a random number between 1 and 20 | |
const number = getRandomInt(20) | |
// change the p tag to show the number | |
const myPTag = $(this).siblings('p') | |
myPTag.text(number) | |
// $('.d20 p').text(number) | |
}) | |
}) | |
function getRandomInt(max) { | |
return 1 + Math.floor(Math.random() * Math.floor(max)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> | |
<script src="script2.js"></script> | |
</head> | |
<body> | |
<div class="d20"> | |
<h2>Roll!</h2> | |
<p>...</p> | |
<button>Roll!</button> | |
</div> | |
<div class="d20"> | |
<h2>Roll!</h2> | |
<p>...</p> | |
<button>Roll!</button> | |
</div> | |
<div class="d20"> | |
<h2>Roll!</h2> | |
<p>...</p> | |
<button>Roll!</button> | |
</div> | |
<button id="catButton">Click me for 🐈</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment