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 trialdatajournalismguy
3,274 Points<script> and <noscript> tags and unobtrusive JavaScript
Hi there,
can't you just use <script> and <noscript> tags to control what users see with disabled JavaScript instead of adding HTML with the jQuery .append() method?
Thanks!
2 Answers
Steven Parker
231,269 PointsIt's not an "instead" situation — you would typically use these things together.
Anything written in jQuery will only run if scripting is enabled, and you might combine this with code inside a <noscript>
tag to display something else when it is not enabled.
datajournalismguy
3,274 PointsThanks! But why can't you just put HTML within a <script> tag? Wouldn't that be easier than inserting HTML with JavaScript/jQuery?
Steven Parker
231,269 PointsI see what you mean, but I guess the creators of HTML probably expected that if you use scripting at all, you probably want to add a some functionality in addition to just displaying some HTML elements, so they left it up to the script code to do that. Not all scripts add anything to the HTML at all.