How do I initialise JQuery on Tumblr? [closed]

邮差的信 提交于 2019-11-28 06:55:29

问题


I'm making a Tumblr theme. I need to use JQuery for a few theme functions, but I need to first initialise it in the JS section of the built in theme editor.

Because this is on Tumblr, I cannot host a JQuery library on my own server. How can I access this library remotely from another source?


回答1:


If you want to use the power of the jQuery javascript library in your Tumblr theme and you don’t want to host the jQuery library on your own server then you should consider the Google AJAX Libraries API. The AJAX Libraries API is a content distribution network and loading architecture for the most popular, open source JavaScript libraries.

Put the following snippet (based on this article) in the head tag of your theme and you’re ready to go:

<script type="text/javascript" 
    src="http://www.google.com/jsapi"></script>

<script type="text/javascript">
  google.load("jquery", "1.3");
  google.setOnLoadCallback(function() {
    jQuery(function($) {
      // do some stuff here, eg load your tweets, ...
    });
  });
</script>

source



来源:https://stackoverflow.com/questions/18576419/how-do-i-initialise-jquery-on-tumblr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!