Javascript Wordpress中的水平滑动面板,显示第一个面板
我在主页上用jQuery创建了一个滑动面板,其中有5个面板,代码如下Javascript Wordpress中的水平滑动面板,显示第一个面板,javascript,jquery,html,wordpress,Javascript,Jquery,Html,Wordpress,我在主页上用jQuery创建了一个滑动面板,其中有5个面板,代码如下 <script type="text/javascript"> jQuery(function($) { $('a.panel').click(function() { var $target = $($(this).attr('href')), $other = $target.siblings('.active'); if (!$target.hasClass('active
<script type="text/javascript">
jQuery(function($) {
$('a.panel').click(function() {
var $target = $($(this).attr('href')),
$other = $target.siblings('.active');
if (!$target.hasClass('active')) {
$other.each(function(index, self) {
var $this = $(this);
$this.removeClass('active').animate({
left: $this.width()
}, 500);
});
$target.addClass('active').show().css({
left: -($target.width())
}).animate({
left: 0
}, 500);
}
});
});
当前我需要单击以查看面板。有没有一种方法可以使第一个面板显示而无需单击
HTML是:
<div class="panel" id="target1" >
<div class="inner blue">
<?php the_field( "dm" );?>
</div>
</div>
<div class="panel" id="target2">
<div class="inner green">
<?php the_field( "rd" );?>
</div>
</div>
<div class="panel" id="target3">
<div class="inner brown">
<?php the_field( "cd" );?>
</div>
</div>
…etc您显示的代码不足以重现问题。请看一下指南