【问题标题】:How to Apply Backstretch to body如何将 Backstretch 应用于身体
【发布时间】:2014-11-09 16:08:01
【问题描述】:

我知道这是一个愚蠢的问题,但我不知道在 Wordpress 上的何处放置此代码

/*
 * Here is an example of how to use Backstretch as a slideshow.
 * Just pass in an array of images, and optionally a duration and fade value.
 */

  // Duration is the amount of time in between slides,
  // and fade is value that determines how quickly the next image will fade in
  $.backstretch([
      "http://dl.dropbox.com/u/515046/www/outside.jpg"
    , "http://dl.dropbox.com/u/515046/www/garfield-interior.jpg"
    , "http://dl.dropbox.com/u/515046/www/cheers.jpg"
  ], {duration: 3000, fade: 750});

这必须在脚本标签之间吗?还是在 PHP 代码中?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
CODE
</script>

谢谢

【问题讨论】:

    标签: javascript jquery ajax wordpress


    【解决方案1】:

    据我所知,backstretch 会在您指定的 div 中附加一个 div。 此外,javascript 是一种客户端语言。无需在 PHP 中执行此操作。

    简单的答案:在 jquery 中加载后,在客户端的两个脚本标签之间添加它。

    【讨论】:

    • 除了 WordPress 已经将 jQuery 加入队列...这样做意味着它被加载了两次。如果 OP 决定使用 WordPress 附带的 jQuery,他/她需要知道$ jQuery 快捷方式默认情况下不起作用。添加它的实际正确方法是将其添加到自己的文件中,并使用wp_enqueue_script() 将其正确排队,并将jquery 作为依赖项。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 2021-06-02
    相关资源
    最近更新 更多