简体   繁体   English

jQuery选项卡不起作用或引用错误?

[英]Jquery tabs not working or wrong references?

What is wrong with this code? 此代码有什么问题? Tabs aren't working: 选项卡不起作用:

<div id="tabs">
    <ul>
        <li><a href="#tabs-1"><span class="tabs-1">Dados Um</span></a>

        </li>
        <li><a href="#tabs-2"><span class="tabs-2">Dados Dois</span></a>

        </li>
        <li><a href="#tabs-3"><span class="tabs-3">Dados Três</span></a>

        </li>
        <li><a href="#tabs-4"><span class="tabs-4">Dados Quatro</span></a>

        </li>
        <li><a href="#tabs-5"><span class="tabs-5">Dados Cinco</span></a>

        </li>
        <li><a href="#tabs-6"><span class="tabs-6">Dados Seis</span></a>

        </li>
    </ul>
    <div id="tabs-1"></div>
    <div id="tabs-2"></div>
    <div id="tabs-3"></div>
    <div id="tabs-4"></div>
    <div id="tabs-5"></div>
    <div id="tabs-6"></div>
</div>

And JS: 和JS:

$(document).ready(function () {
    $("#tabs").tabs();

    $('.tabs-2').bind("click", tabs2);
    $('.tabs-3').bind("click", tabs3);
    $('.tabs-4').bind("click", tabs4);
    $('.tabs-5').bind("click", tabs5);
};

function tabs2() {
    alert("hi");
};

And JSFiddle here 还有JSFiddle 在这里

Check this out: http://jsfiddle.net/Aw43k/1/ 检查一下: http : //jsfiddle.net/Aw43k/1/

Looks like the problem with your JSFiddle was that it was missing jQuery and jQueryUI. 看来您的JSFiddle的问题是缺少jQuery和jQueryUI。 Also jQuery on ready function is not needed. 另外,不需要jQuery的ready函数。

$("#tabs").tabs(); 

$('.tabs-2').bind("click", tabs2);
$('.tabs-3').bind("click", tabs3);
$('.tabs-4').bind("click", tabs4);
$('.tabs-5').bind("click", tabs5);

function tabs2() {
  alert("hi");
}

Can you please check http://jsfiddle.net/y2FCK/1/ 能否请您检查http://jsfiddle.net/y2FCK/1/

$("#tabs").tabs(); 

$('.tabs-2').bind("click", tabs2);
$('.tabs-3').bind("click", tabs3);
$('.tabs-4').bind("click", tabs4);
$('.tabs-5').bind("click", tabs5);

function tabs3() {
   alert("clicked tab3");
};

Added Jquery UI js in fiddle and also you need to include the same in your project file: 在小提琴中添加了Jquery UI js,并且您还需要在项目文件中包含相同的内容:

 <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM