Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsExperiment with the app
Hi guys just wanted to share my program. Dave McFarland asked us to experiment with the app in the Select page element by ID lesson.
video link: https://teamtreehouse.com/library/select-a-page-element-by-its-id
Just wanted to share my code.
The first input changes the color the second changes the font size. It accepts all the units, px, em, rem,%.
<!DOCTYPE html>
<html>
<head>
<title>JavaScript and the DOM</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h1 id="myHeading">JavaScript and the DOM</h1>
<p>Making a web page interactive</p>
<input type="text" name="" value="" id="myTextInput">
<button type="button" name="button" id="myButton">Change Headline color</button>
<input type="text" name="" value="" id="changeStyle">
<button type="button" name="button" id="fontSize">Change font size</button>
<button type="button" name="button" id="reset">Reset Button</button>
<script src="js/app.js"></script>
</body>
</html>
const myHeading = document.getElementById('myHeading');
const myButton = document.getElementById('myButton');
const myTextInput = document.getElementById('myTextInput');
const reset = document.getElementById('reset');
const changeStyle = document.getElementById('changeStyle');
const fontSize = document.getElementById('fontSize');
myButton.addEventListener('click', () => {
myHeading.style.color = myTextInput.value;
});
fontSize.addEventListener('click', () => {
myHeading.style.fontSize = changeStyle.value;
});
reset.addEventListener('click', () => {
myHeading.style.color = '#363636';
myHeading.style.fontSize = '2em';
});
feedback?