为什么这个js手风琴不起作用


I'm trying to get Jquery accordion working but I can't seem to.
Here is the code
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>accordion demo</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
    <div id="accordion">
         <h3>Read More</h3>
        <div>
            <p>Whether you choose to create a healthier lifestyle, deeper relationships, or seek more fulfillment in your career, TeamUp will take you there.</p>
            <p>You’ll discover your <b>patterns of behavior</b> and consciously choose which ones to keep and which ones to change. You'll experience your life from a new and refreshing perspective.</p>
        </div>
    </div>
<script>
$( "#accordion" ).accordion();
</script>
</body>

这是我在JSFiddle上所做的

http://jsfiddle.net/CQu35/

任何帮助表示赞赏

谢谢

我能看到的唯一问题是使用相对协议,如果文件是从本地文件系统加载的,它将不起作用

  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

你的 jsfiddle 有问题,因为它看起来 jsfiddle 不包括 jQuery-ui.js 文件

如果您符合以下条件,则可以正常工作:

  • 使用 jQuery 2.02
  • 使用 JQuery UI 1.10.3
  • 在手风琴参数中设置collapsible: true(默认情况下,手风琴始终保持一个部分打开)

    $( "#accordion" ).手风琴({ 可折叠:真});

看起来问题只出在您的小提琴上。我将您的整个代码粘贴在 jsfiddle 中,它看起来可以正常工作。

Same code pasted in your question

http://jsfiddle.net/sajith/VQ6z2/

最新更新