我不明白为什么jQuery函数不起作用。我在网上读到了如何在wordpress中加载jQuery,但没有成功。有人能帮我吗?
到目前为止,我所做的是:我把这个放在标题中。php内部标记:
<?php wp_enqueue_script("jquery"); ?>
<?php wp_head(); ?>
<script type="text/javascript" src="<?php bloginfo(\'template_url\'); ?>/wp-includes/js/jquery/slideshow1.js"></script>
用于jquery的css样式:
#gallery1{
float:right;
width:400px; /* Set your image width */
height:300px; /* Set your image height */
}
#gallery1 img{
position:absolute;
z-index:8;
}
#gallery1 img.active{
z-index:10;
}
#gallery1 img.last-active{
z-index:9;
}
html代码:
幻灯片1。js公司:
function slideSwitch() {
var $active = $(\'#gallery1 IMG.active\');
if ( $active.length == 0 ) $active = $(\'#gallery1 IMG:last\');
var $next = $active.next().length ? $active.next()
: $(\'#gallery1 IMG:first\');
$active.addClass(\'last-active\');
$next.css({opacity: 0.0})
.addClass(\'active\')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass(\'active last-active\');
});
}
$(function() {
setInterval( "slideSwitch()", 5000 );
});
我读到我需要将$更改为其他内容,如“jQuery”。我试过了,但也没有成功。有人能帮我吗?