Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.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 jQuery选项卡";“未定义”不是一个函数;_Javascript_Jquery_Css_Tabs - Fatal编程技术网

Javascript jQuery选项卡";“未定义”不是一个函数;

Javascript jQuery选项卡";“未定义”不是一个函数;,javascript,jquery,css,tabs,Javascript,Jquery,Css,Tabs,我最近一直在尝试使用或熟悉JQuery选项卡函数。然而,每次我尝试使用它时,我都会得到一个错误“undefined不是一个函数”。我已经研究过这个问题,很多人说它可能与没有加载.js文件有关,但事实并非如此,因为我的控制台选项卡显示它正在加载 以下是我一直尝试测试的HTML文件: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <titl

我最近一直在尝试使用或熟悉JQuery选项卡函数。然而,每次我尝试使用它时,我都会得到一个错误“undefined不是一个函数”。我已经研究过这个问题,很多人说它可能与没有加载.js文件有关,但事实并非如此,因为我的控制台选项卡显示它正在加载

以下是我一直尝试测试的HTML文件:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
    <link rel="stylesheet" type="text/css" href="Portal.css" media="screen" />
    <script type="text/javascript" src="Portal.js"></script>  
    <script src="tabs.js"></script>
    </head>
    <body>


    <div id="tabs">
    <ul>
    <li><a href='#tab1'>Tab 1</a></li>
    <li><a href='#tab2'>Tab 2</a></li>
    <li><a href='#tab3'>Tab 3</a></li>
  </ul>
  <div id='tab1'>
       <p>Hi, this is the first tab.</p>
  </div>
  <div id='tab2'>
    <p>This is the 2nd tab.</p>
      </div>
     <div id='tab3'>
                   <p>And this is the 3rd tab.</p>
             </div>
               </div>

    </body>
    </html>

谢谢。如果需要,我可以提供更多细节。还没有使用CSS(但我不认为这是问题所在)。

您选择的是类选项卡,但您拥有的是ID选项卡

将其更改为:

$( 'div#tabs' ).tabs();
或将您的HTML更改为:

class="tabs"

您正在选择类选项卡,但您拥有的是ID选项卡

将其更改为:

$( 'div#tabs' ).tabs();
或将您的HTML更改为:

class="tabs"

$(“#tabs”).tabs()
使用此选项而不是
$(“div.tabs”).tabs()
$(“#tabs”).tabs()
使用此选项而不是
$(“div.tabs”).tabs()

确保您从外部源加载js

我也有类似的问题。我的代码在konqueror、opera和一些firefox/iceweasel浏览器中工作,但在其他浏览器和chromium浏览器中都不工作

事实证明,虽然我的页面是https托管的,但我试图通过不安全的http连接加载外部js。这些链接被“不工作”的浏览器悄悄地丢弃。。。我在那架飞机上花了好几个小时


希望这对您或其他人有所帮助。

请确保您正在从外部源加载js

我也有类似的问题。我的代码在konqueror、opera和一些firefox/iceweasel浏览器中工作,但在其他浏览器和chromium浏览器中都不工作

事实证明,虽然我的页面是https托管的,但我试图通过不安全的http连接加载外部js。这些链接被“不工作”的浏览器悄悄地丢弃。。。我在那架飞机上花了好几个小时

希望这对您或其他人有所帮助。

旁注:
$(“#tabs”)
会更快。您加载了tabs()插件代码了吗?如果你这样做,你能告诉哪里/哪个代码抛出错误吗?旁注:
$(“#tabs”)
会更快。你加载了tabs()插件代码了吗?如果您这样做,您能告诉哪里/哪个代码抛出错误吗?