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 trialjayshi
5,950 Pointswhy does the button cover the spoiler content? Do they use CSS to do that?
So the when we click the button, the spoiler appears right at where the button was. I am just wondering if they use CSS to do that, or is it related to "append()" ?
3 Answers
Ella Ruokokoski
20,881 Pointsthe .append() method appends/inserts the created <button> html element to the element with a class of spoiler:
var button = $('<button>Reveal Spoiler!</button>');
$(".spoiler").append(button);
the text inside the p elements with the class of spoiler was hidden with the . hide() method.
Carlos Alberto Del Cueto Carrejo
13,817 PointsElla Ruokokoski great answer, I can also add that you can check in real time what a Jquery method is doing with the DOM by opening the JavaScript console , Ctrl + Shift + J on most browsers, and interacting with the buttons. All changes will be highlighted.
Michal Janek
Front End Web Development Techdegree Graduate 30,654 PointsAnd it covers the whole spoiler area because of css. The width of the button is set to cover the whole area.