jQuery手风琴无法正常工作 [英] jQuery accordion its not working

查看:95
本文介绍了jQuery手风琴无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jQuery ui手风琴插件,但我不知道为什么它不起作用.

I'm trying to use the jquery ui accordion plugin and I don't know why its not working.

我来到 http://jqueryui.com/并阅读了文档,我选择了一个主题,然后我选择"UI核心全部切换",然后在窗口小部件中仅选择手风琴".

I came to http://jqueryui.com/ and read the documentation, I choose a theme and then I selected "UI Core toggle all", and then in widgets I selected only "Accordion".

我将文件保存在"acc"文件夹中,然后按如下所示导入文件:

I save the files in my "acc" folder and then I import the files like this:

<link rel="stylesheet" type="text/css" href="../acc/css/jquery-ui-style.css" />
<title>Projet</title>
<script type="text/javascript" src="../acc/js/jquery.js"></script>
<script type="text/javascript" src="../acc/js/jquery-ui.js"></script>
<script type="text/javascript" src="../acc/js/acc.js"></script>

然后在我的 acc.js文件中,我正在启动手风琴:

And then in my acc.js file Im starting accordion:

$(function (){
    $('.accordion').accordion();
});

但是它不起作用,我只有我的普通html,没有手风琴.

But its not working, I'm having only my normal html without the accordion.

我的html 是这样:

 <div class="accordion">

        <h3>Title 1</h3>    
        <div>
            <p>My first post.</p>
        </div>        

        <h3>Title 2</h3>
        <div>
            <p>My second post.</p>  
        </div>        

        <h3>Title 3</h3>
        <div>
            <p>My third post</p>    
        </div>

    </div><!-- /accordion -->   

推荐答案

从您发布的代码来看,它应该可以正常工作,所以我只能假设它没有正确包含您的脚本

From the code you have posted it should work so I can only assume it isn't including your scripts properly

如果acc文件夹位于网站的根文件夹中,则应考虑将脚本和CSS更改为:

If the acc folder is in the root folder of your website you should consider changing your scripts and css to:

<link rel="stylesheet" type="text/css" href="/acc/css/jquery-ui-style.css" />
<script type="text/javascript" src="/acc/js/jquery.js"></script>
<script type="text/javascript" src="/acc/js/jquery-ui.js"></script>
<script type="text/javascript" src="/acc/js/acc.js"></script>

删除圆点-这意味着您要尝试从所在位置(在url中,而不是带有html的文件中)到上一个文件夹.

Remove the dots - as that means you are trying to get to a folder one up from where you are (in the url, not the file with the html).

如果这不起作用,请按f12键并检查您的控制台,您可能会遇到其他js错误,从而使手风琴无法正常工作

If this doesn't work then press f12 and check your console, you may have other js errors stopping the the accordion working

这篇关于jQuery手风琴无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆