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
jin-wook ro
Full Stack JavaScript Techdegree Student 103 PointsWhen using images(.png) for javascript, does the file have to be in the same directory?
When using images(.png) for javascript, does the file have to be in the same directory? If it is in the sub-directory, do I have to use '/folder_name/file.png'? what if the file is in super-directory?
1 Answer
Steven Parker
243,266 PointsIf a file is in a different directory, just prefix the file name with a path. The path can be absolute (beginning with "/") or relative to the current directory.
If the location is in a parent ("super") directory, use the special symbols "../" for each level to go up.