如何在Tumblr上初始化JQuery? [英] How do I initialise JQuery on Tumblr?

查看:97
本文介绍了如何在Tumblr上初始化JQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个Tumblr主题.我需要对一些主题函数使用JQuery,但首先需要在内置主题编辑器的JS部分中对其进行初始化.

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.

因为这是在Tumblr上,所以我无法在自己的服务器上托管JQuery库.如何从另一个来源远程访问该库?

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?

推荐答案

如果您想在Tumblr主题中使用jQuery javascript库的强大功能,并且不想在自己的服务器上托管jQuery库,那么您可以应该考虑使用Google AJAX库API. AJAX库API是最流行的开源JavaScript库的内容分发网络和加载体系结构.

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>

这篇关于如何在Tumblr上初始化JQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆