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
Anthony Domina
Courses Plus Student 19,571 PointsNeed button label to come from a paragraph's ID
I am making a quiz with multiple choice questions. Instead of having the text of the choice above the button, I want to try having the choice as the label FOR the button.
With the code below the goal is to get rid of "Select Answer" and in its place put in #choice1.
<p id="choice1"></p> <button id="guess1" class="btn--brown">Select Answer</button>
Is there an easy way to do this? Any thoughts would be appreciated.
3 Answers
Anthony Domina
Courses Plus Student 19,571 PointsSolved my own problem. I just needed to use a Span tag and assign the paragraph's ID to it instead.
<button id="guess0" class="btn--brown"><span id="choice0"></span></button>
Dalton Dunn
6,709 PointsIf I am understand the question correctly you just want the choice ex("George Washington") as the answer to the frist president of the USA. If I am understanding it correctly than you've done it all you have to do is just change Select Answer to the choice. Please explain more if I am not understanding correctly and I will try to assist further
Anthony Domina
Courses Plus Student 19,571 PointsThat is exactly what I am needing, and props for recognizing this from the object oriented JavaScript exercise!
So ,yes, trying to figure out how I could get the button to say George Washington and then automatically change to PI when it shifts to question 2
Dalton Dunn
6,709 PointsDalton Dunn
6,709 PointsAwesome! I totally forgot to respond back to collaborate about this as I was a little confused as well about but I went home from work and totally forgot you responded back