2012-12-03 114 views
1

目前我尝试下面的星级插件添加到我的WordPress博客:FYNEWORKSjQuery的星级评定工作不

但出于某种原因,我似乎并没有工作。我对jQuery完全陌生,所以希望你能帮助我。

加到首:

<script type="text/javascript" src="/wp-content/themes/wordpress-naked/js/jquery.js"/> 
    <script type="text/javascript" src="/wp-content/themes/wordpress-naked/js/jquery.rating.js"/> 
    <script type="text/javascript" src="/wp-content/themes/wordpress-naked/js/jquery.form.js"/> 
    <script type="text/javascript" src="/wp-content/themes/wordpress-naked/js/jquery.MetaData.js"/> 
    <script type="text/javascript" src="/wp-content/themes/wordpress-naked/js/jquery.rating.pack.js"/> 

而且也在标题:

<script type="text/javascript"> 
jQuery(function($){ 
    ('.hover-star').rating({ 
     focus: function(value, link){ 
      var tip = $('#hover-test'); 
      tip[0].data = tip[0].data || tip.html(); 
      tip.html(link.title || 'value: '+value); 
     }, 
     blur: function(value, link){ 
      var tip = $('#hover-test'); 
      $('#hover-test').html(tip[0].data || ''); 
     } 
    }); 
}); 
</script> 

我的CSS文件:

/* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */ 
div.rating-cancel,div.star-rating{float:left;width:17px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden;} 
div.rating-cancel,div.rating-cancel a{background:url("/wp-content/themes/wordpress-naked/js/delete.gif") no-repeat 0 -16px; !important} 
div.star,div.star a{background:url("/wp-content/themes/wordpress-naked/js/star.gif") no-repeat 0 0px; !important} 
div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0 !important;} 
div.star-rating-on a{background-position:0 -16px!important;} 
div.star-rating-hover a{background-position:0 -32px;} 
/* Read Only CSS */ 
div.star-rating-readonly a{cursor:default !important;} 
/* Partial Star CSS */ 
div.star-rating{background:transparent!important;overflow:hidden!important;} 
/* END jQuery.Rating Plugin CSS */ 

我的单选按钮有作为定义的类第二个代码部分“.hover-star。

但是,它仍然无法正常工作。我犯了一个错字还是我忽略了一些东西?

日Thnx :)

+0

尝试加入'$''这里$( '悬停星。')评级({'' –

回答

0

文档完全载入后,否则执行太早,此项目将不会被发现,你的脚本应该总是启动。

$(document).ready(function() { ... // your code // ... }) 

wirey是正确的太对失踪$

+0

$(函数()==''$(文件)。就绪(函数()'HTTP:// api.jquery.com/ready/ –

+0

哎呀不知道自己:( –

+0

现在你:)如果允许这只是一个速记/快捷版 –

0

首先,你是不是在这里呼吁的jQuery:

('.hover-star').rating({

你需要调用的jQuery与$jQuery

$('.hover-star').rating({

也可能有其他问题。我会建议使用调试器。它会帮助找到这个问题和其他问题。

+0

增加了$符号,使jQuery将调用它。至今没有运气,但我真的很感激快速回复:) – Regenbui