Created
April 29, 2011 06:16
-
-
Save ryansukale/947930 to your computer and use it in GitHub Desktop.
Find the current directory of your script from within your javascript using jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This code returns the path of the currently executing javascript file. This path can then be used to find relative paths to other files like the css files and images that are specific to this js file. | |
Should come in handy when making jQuery plugins if your script file makes used of script specific css. You can simply use string manipulation to create the relative path for your css. | |
Recommended use at the top of your plugin. | |
*/ | |
var jsFilePath = $("head").find("script:last").attr('src'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment