How to add jQuery in JS file

后端 未结 19 645
星月不相逢
星月不相逢 2020-12-04 05:47

I have some code specific to sorting tables. Since the code is common in most pages I want to make a JS file which will have the code and all the pages using it can referen

相关标签:
19条回答
  • 2020-12-04 06:22

    If you frequently want to update your jquery file link to a new version file, across your site on many pages, at one go..

    Create a javascript file (.js) and put in the below code, and map this javascript file to all the pages (instead of mapping jquery file directly on the page), so when the jquery file link is updated on this javascript file it will reflect across the site.

    The below code is tested and it works good!

    document.write('<');
    document.write('script ');
    document.write('src="');
    //next line is the path to jquery file
    document.write('/javascripts/jquery-1.4.1.js');
    document.write('" type="text/javascript"></');
    document.write('script');
    document.write('>');
    
    0 讨论(0)
提交回复
热议问题