Jquery的强大相信使用wordpress主题的各位都非常清楚,很多WordPress主题中都有加载jquery来实现一些特效,比如滑动菜单、图片幻灯等,只有你想不到,没有J做不到的。。
图片特效
header.php
文件修改:
加载jquery,可以使用外链也可以内链。
外链可以利用google为我们提供的JS库,据说可以提高js加载速度。
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"></script>
内链方式:[上传jquery.min.js至 你主题目录/js
]
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.min.js" ></script>
在header.php
适当位置中添加:
<script type="text/javascript"> $(function () { $('img').hover( function() {$(this).fadeTo("fast", 0.5);}, function() {$(this).fadeTo("fast", 1); }); }); </script>
另一种是鼠标悬停到图片上时,图片变得清晰~:
<script type="text/javascript"> $(function() { $('img').animate({"opacity": .5 }); $('img').hover(function() { $(this).stop().animate({ "opacity": 1 }); }, function() { $(this).stop().animate({ "opacity": .5 }); }); }); </script>