Плагин Easy Tabs, всегда прокручивайте вверх

0

Привет, я использую JQuery EasyTabs Plugin для моего сайта, следуйте инструкциям в онлайн- плагине JQuery EasyTabs. Кажется, он работает нормально; однако, когда я нажимаю на каждую вкладку, она всегда переходит в верхнюю часть, как "# tap1", в отличие от ее демонстрации. Я также проверил путь включения его необходимых файлов js, css и jquery, они уже верны. Вот требуемые файлы js и css

<script type='text/javascript' src='style/jquery.js'></script>
<script src="style/jquery.hashchange.js" type="text/javascript"></script>
<script src="style/jquery.easytabs.js" type="text/javascript"></script>
<link href="style/tabs.css" rel="stylesheet" type="text/css">

и это мой HTML для вкладок

        <!-- TABS -->
<div id='e-tabs' style='width:720px;height:auto;float:left;'>
            <div id="tab-container" class="tab-container">
          <ul class='etabs'>
            <li class='tab'><a href="#tabs1-html">Fatures</a></li>
            <li class='tab'><a href="#tabs1-js">Most Recent</a></li>
            <li class='tab'><a href="#tabs1-css">Most Popular</a></li>
          </ul>
          <div id="tabs1-html">
<!--            <h2>HTML Markup for these tabs</h2> -->
                <!-- content -->
                <div id='space'></div>
                    <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
          </div>
          <div id="tabs1-js">
        <!--        <h2>JS for these tabs</h2> -->
                <!-- content -->

                    <div id='space'></div>
                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>


          </div>
          <div id="tabs1-css">
        <!--    <h2>CSS Styles for these tabs</h2> -->
            <!-- content -->
            <div id='space'></div>
                <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
                                        <div id='ads'>
                    <img src='ads-image\1.jpg'>
                    <div id='ads-title'><h4>Car for Sale</h4></div>
                    <div id='ads-price'><p>500$</p></div>
                    </div>
          </div>
        </div>
</div>
        <!-- TABS -->

Может кто-нибудь мне помочь? дайте мне знать, если вам нужна дополнительная информация, спасибо

  • 0
    Есть ли какие-либо ошибки JavaScript в консоли?
  • 0
    Да, в консоли инспектора Firefox это SyntaxError: Using //@ to indicate source map URL pragmas is deprecated. Use //# instead. jquery.min.js:1 The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contians characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. index.html Use of the getPreventDefault() is deprecated. Use defaultPrevented instead. jquery-2.0.3.js
Показать ещё 5 комментариев

1 ответ

1
Лучший ответ

У меня была такая же проблема в Google Chrome 39, но не в Firefox или Safari.

Проблема заключается в том, что Google Chrome 39 перейдет к элементу с идентификатором хэша, когда будет обновлено location.hash.

Вы можете исправить это, изменив jquery.easytabs.js версии 3.2.0, чтобы обновить хэш, используя history.pushState({}, "", newHash) вместо location.hash = newHash. Этот запрос на растяжение уже делает это за вас.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню