利用jquery实现图片高亮
首先需要在header.php中加载jquery,可以使用外链也可以内链。
外链可以利用google为我们提供的JS库,可以提高js加载速度,代码如下:
1  | <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"></script>  | 
1  | 内链格式:  | 
1  | <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.min.js" ></script>  | 
1  | 然后再在header.php中添加如下代码:  | 
1  | <script type="text/javascript">  | 
1  | $(function() {  | 
1  | $('img').animate({"opacity": .5 });  | 
1  | $('img').hover(function() {  | 
1  | $(this).stop().animate({ "opacity": 1 });  | 
1  | }, function() {  | 
1  | $(this).stop().animate({ "opacity": .5 });  | 
1  | });  | 
1  | });  | 
1  | </script>  | 
1  | 好了,ok!  |