Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.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
Jquery ui ajaxjqueryui手风琴_Jquery Ui_Accordion - Fatal编程技术网

Jquery ui ajaxjqueryui手风琴

Jquery ui ajaxjqueryui手风琴,jquery-ui,accordion,Jquery Ui,Accordion,我用以下方式开始我的手风琴: $(function() { $("#gallery_accordion").accordion({ event: false }); $("#gallery_accordion").click(function(e) { var contentDiv = $(this).next("div"); contentDiv.load($(this).find("a").attr("href")); }); }); 内容在单击时加载,但手风

我用以下方式开始我的手风琴:

$(function() {
  $("#gallery_accordion").accordion({ event: false });
  $("#gallery_accordion").click(function(e) {
    var contentDiv = $(this).next("div");
    contentDiv.load($(this).find("a").attr("href"));
  }); 
});
内容在单击时加载,但手风琴不可见。 没有显示任何内容。非常感谢您的帮助。 谢谢

更新:高度保持在“0”。有什么原因吗

以下是标记:

<div id="gallery_accordion">
    <h3><a href="javascript:getGallery('369');">My first gallery</a></h3>
    <div id="gallery369">
    </div>

    <h3><a href="javascript:getGallery('381');">The second gallery</a></h3>
    <div id="gallery381">
    </div>
</div>

尝试将初始呼叫更改为:

$("#gallery_accordion").accordion({ header: "h3", event : false });
以及您的HTML地址:

<div id="gallery_accordion">
<div>
    <h3><a href="javascript:getGallery('369');">My first gallery</a></h3>
    <div id="gallery369">
    </div>
</div>
<div>
    <h3><a href="javascript:getGallery('381');">The second gallery</a></h3>
    <div id="gallery381">
    </div>
</div>
</div>
您的每个单元格都需要有自己的div标记,在初始调用中,您现在已将标题设置为H3标记

希望这有帮助

下面是加载手风琴的示例文档:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>jQuery UI Example Page</title>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/start/jquery-ui.css" rel="Stylesheet" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function(){
                // Accordion
                $("#gallery_accordion").accordion({ header: "h3"});
                $("#gallery_accordion a").click(function(evt) {
          var galleryId = $(this).attr('href').split('#')[1];
          var contentDiv = $('#' + 'gallery' + galleryId);
          if(contentDiv.html() == "&nbsp;") {
            var galleryContent = getGallery(galleryId);
            contentDiv.html(galleryContent);
          }
        });
                var galleryIdI = $('#gallery_accordion div div:first').attr('href').split('#')[1];
        var contentDivI = $('#' + 'gallery' + galleryId);
                var galleryContentI = getGallery(galleryId);
                contentDivI.html(galleryContentI);
            });
        </script>
    </head>
    <body>
    <!-- Accordion -->
        <h2 class="demoHeaders">Accordion</h2>
        <div id="gallery_accordion">
            <div>
                <h3><a href="#369">Gallery 1</a></h3>
                <div id="gallery369">&nbsp;</div>
            </div>
            <div>
                <h3><a href="#381">Gallery 2</a></h3>
                <div id="gallery381">&nbsp;</div>
            </div>
            <div>
                <h3><a href="#392">Gallery 3</a></h3>
                <div id="gallery392">&nbsp;</div>
            </div>
        </div>
</body>
</html>

你能包括手风琴的标记是什么样子的吗?我添加了div并在init中添加了'header:h3',但不幸的是它没有帮助。只需问一下,你的文档中引用了JQuery和JQuery UI js文件以及JQuery UI css文件,对吗?下面是你的示例:不幸的是,我无法使其正常运行。如果您想知道为什么单击标题时单元格不会更改,则需要从初始调用中删除event:false。这将使手风琴功能点击。您到底遇到了什么问题?当我删除event:false时,没有加载任何内容。没有获取div内容的调用。不调用click函数。