Wordpress javascript如何工作?

Wordpress javascript如何工作?,javascript,wordpress,Javascript,Wordpress,各位 我是wordpress的新手。我正在将html模板转换为wordpress。 脚本如下所示: <script src="js/jquery.min.js"></script> <script src="js/jquery.nicescroll.min.js"></script> javascript函数包括: <script> var nice = false; $(document).ready(function

各位

我是wordpress的新手。我正在将html模板转换为wordpress。 脚本如下所示:

<script src="js/jquery.min.js"></script>
<script src="js/jquery.nicescroll.min.js"></script>

javascript函数包括:

<script>
  var nice = false;

  $(document).ready(function() {
    nice = $("html").niceScroll();
  });

  var obj = window;//$(window);

  console.log(obj.length);
  console.log("selector" in obj);

</script>

<script>

  function toCell(px,py,ok) {
    $("#tab1").find('tr').eq(py).find('td').eq(px).addClass((ok)?'testok':'testko');
  };

  $(window).load(function() {
    $("#div1").html($("#div1").html()+' '+nice.version);
    $("#div2").html($("#div2").html()+' '+navigator.userAgent);

    toCell(1,1,nice.detected.ismozilla);

    toCell(2,1,(nice.detected.prefixstyle=='-webkit-'));

    toCell(3,1,nice.detected.isie);
    toCell(3,2,nice.detected.isie10);
    toCell(3,3,nice.detected.isie9);
    toCell(3,4,nice.detected.isie8);
    toCell(3,5,nice.detected.isie7);
    toCell(3,6,nice.detected.isieold);

    toCell(4,1,nice.detected.isopera);

    toCell(5,1,nice.detected.isios);
    toCell(5,2,nice.detected.isios4);

    toCell(0,8,nice.detected.cantouch);
    toCell(3,8,nice.detected.hasmstouch);

    toCell(1,10,nice.detected.hastransform);
    toCell(1,11,nice.detected.hastranslate3d);
    toCell(2,10,nice.detected.hastransition);
    toCell(2,11,!!nice.detected.transitionend);
    toCell(3,10,nice.hasanimationframe);
    toCell(3,11,nice.hascancelanimationframe);

    toCell(1,12,nice.detected.hasmousecapture);
    toCell(2,12,((nice.detected.cursorgrabvalue!='')&&(nice.detected.cursorgrabvalue.substr(0,3)!='url')));


  });

</script>

var nice=false;
$(文档).ready(函数(){
nice=$(“html”).nicesroll();
});
var obj=窗口//$(窗口);
控制台日志(对象长度);
console.log(obj中的“选择器”);
功能到单元(px、py、ok){
$(“#tab1”).find('tr').eq(py).find('td').eq(px).addClass((ok)-'testok':'testko');
};
$(窗口)。加载(函数(){
$(“#div1”).html($(“#div1”).html()+''+nice.version);
$(“#div2”).html($(“#div2”).html()+''+navigator.userAgent);
toCell(1,1,nice.detected.ismozilla);
toCell(2,1,(nice.detected.prefixstyle='-webkit-');
toCell(3,1,nice.detected.isie);
toCell(3,2,nice.detected.isie10);
toCell(3,3,nice.detected.isie9);
toCell(3,4,nice.detected.isie8);
toCell(3,5,nice.detected.isie7);
toCell(3,6,nice.detected.isiold);
toCell(4,1,nice.detected.isopera);
toCell(5,1,nice.detected.isios);
toCell(5,2,nice.detected.isios4);
toCell(0,8,nice.detected.cantouch);
toCell(3,8,不错。检测到。hasmstouch);
toCell(1,10,nice.detected.hastransform);
toCell(1,11,nice.detected.hastranslate3d);
toCell(2,10,nice.detected.hastransition);
toCell(2,11,!!不错。检测到。转换为D);
toCell(3,10,nice.hasanimationframe);
toCell(3,11,nice.hascancelanimationframe);
toCell(1,12,nice.detected.hasmousecapture);
toCell(2,12,((nice.detected.cursorgrabvalue!='')和&(nice.detected.cursorgrabvalue.substr(0,3)!='url');
});
我知道注册、排队,但如何将其转换为wordpress主题


从技术上讲,您可以像在普通网站上一样,在
中包含JavaScript文件。但是
注册
排队
是WordPress的首选机制

您还可以将
直接放在
header.php
中,这将使它在所有页面上都可用。但是,我强烈建议您将其设置为外部脚本


根据文件的排队方式,它将分别使用
wp\u head()
wp\u footer()
添加到站点页眉或页脚

看起来这段代码生成了一个兼容性表?您希望div1和div2的确切位置是页眉还是页脚,还是在一个页面内的某个位置?值得指出的是,默认情况下,jQuery的一个版本是在Wordpress中注册的。