Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Wordpress中的水平滑动面板,显示第一个面板_Javascript_Jquery_Html_Wordpress - Fatal编程技术网

Javascript Wordpress中的水平滑动面板,显示第一个面板

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

我在主页上用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')) {
        $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

您显示的代码不足以重现问题。请看一下指南