在wordpress中的knob.js不工作圆计数器

时间:2014-01-27 01:04:22

标签: jquery wordpress-plugin wordpress-theming wordpress

我正在尝试使用knob.js

在wordpress中添加循环计数器

这是一个例子

jQuery('.knob').each(function () {

   var $this = $(this);
   var myVal = $this.attr("rel");
   // alert(myVal);
   $this.knob({

   });

   $({
       value: 0
   }).animate({

       value: myVal
   }, {
       duration: 2000,
       easing: 'swing',
       step: function () {
           $this.val(Math.ceil(this.value)).trigger('change');

       }
   })

});

样本 http://jsfiddle.net/bowenac/eea52/

这是knob.js文件 https://raw.github.com/aterrien/jQuery-Knob/master/js/jquery.knob.js

我根本无法在wordpress中使用它。有人在wordpress中使用了knob.js吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

我搞定了......我忘了添加jQuery并且必须编辑knob.js以及最终使用它。

jQuery(document).ready(function($) {
$('.knob').each(function() {

           var $this = $(this);
           var myVal = $this.attr("rel");
           // alert(myVal);
           $this.knob({

           });




           $({
               value: 0
           }).animate({

               value: myVal
           }, {
               duration: 2000,
               easing: 'swing',
               step: function () {
                   $this.val(Math.ceil(this.value)).trigger('change');

               }
           })

       });
});