Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress WordPress Theme Development Working with CSS and JS in WordPress Themes How to Link to JS from functions.php File

Do I have to delete $(document).foundation(); from index.html since we moved it to app.js?

Hello,

Since we moved the $(document).foundation(); function from index.html and wrapped it in the jQuery (document).ready function in app.js, am I supposed to delete it from index.html now?

This was what was in index.html: <script> $(document).foundation(); </script>

Then it was moved to app.js (with some other code) like this: jQuery(document).ready(function($) {

$(document).foundation();

$( ".nav-toggle" ).click(function() {
  $(this).toggleClass("open");
  $("nav").fadeToggle(100);

  return false;
});

});

So now do I have to delete it from index.html or do not delete it?

2 Answers

yes since you have migrated your JavaScript to its own file. make sure that the file is linked to your html pages, best practices is to do this with script tags at the end of your document right before the closing body tag. also will need to link Jquery to your project as well this is best done by using a CDN and Jquery site as a link to that here http://jquery.com/download/

also google has one as well. place <script>your </script> tags after the <script>Jquery library tag</script>s so that your javascript will be of higher hierarchy between your scripts and Jquerys library. (sorry if my answer is long winded just want to make sure I have bases covered some of the info maybe redundant to you)

Greg Schudel
Greg Schudel
4,090 Points

Correct me if I'm wrong, but I believe the answer is yes, erase that small snipped code from that index.html file

yes since you have migrated your JavaScript to its own file. make sure that the file is linked to your html pages, best practices is to do this with script tags at the end of your document right before the closing body tag. also will need to link Jquery to your project as well this is best done by using a CDN and Jquery site as a link to that here http://jquery.com/download/

Trace, correct me if I'm wrong, but Zac uses a different solution to attach jquery and script files within the function file. . He explains this around the middle/end of the video. Lemme know if I misunderstood your answer or the video. And thanks for being helpful!