简体   繁体   English

WordPress中的Javascript手风琴菜单问题

[英]Javascript accordion menu problem in WordPress

hi all i am working on wordpress project there is i used accordion for right sidebar but all the link are over lapping each other in IE8 its working fine mozzila so plz help my code is 嗨,我正在从事wordpress项目,我在右侧栏上使用了手风琴,但是在IE8中所有链接相互重叠,因此可以正常工作,所以请帮助我的代码是

<script>
var parentAccordion=new TINY.accordion.slider("parentAccordion");
parentAccordion.init("acc","h4",1,-1);

var nestedAccordion=new TINY.accordion.slider("nestedAccordion");
nestedAccordion.init("nested","h4",1,-1,"acc-selected");
</script>

<div class="widget-container widget_categories">
<?php
$args = array('parent'=>0,'hide_empty'=>0);
$cats = get_categories($args);

echo '<ul id="acc" class="acc">';
foreach($cats as $key => $val)
{
    $args1=array(
        'showposts' => 10,
        'category__in' => array($val->term_id),
        'caller_get_posts'=>1
    );
    $post=get_posts($args1);

    echo '<li><h4>'.$val->name.'</h4>';
    echo '<div class="" style="opacity: 0; height: auto;">';
    echo '<ul id="nested" class="acc">';

    if(isset($post) && !empty($post))
    {
        foreach($post as $key1 => $val1)
        {
            echo '<li class="cat-item"><a title='.$val1->post_title.' href='.$val1->guid.'>'.$val1->post_title.'</a>';
        }
    }

    $subcats = get_categories(array('parent'=>$val->term_id,'hide_empty'=>0));

    if(isset($subcats) && !empty($subcats))
    {

        foreach($subcats as $k => $v)
        {
            echo '<li><h4 class="">'.$v->name.'</h4>';

            $args2=array(
                'showposts' => 10,
                'category__in' => array($v->term_id),
               'caller_get_posts'=>1
            );
            $post1=get_posts($args2);

            if(isset($post1) && !empty($post1))
            {
                echo '<div class="" style="opacity: 1; height: auto;">';
                echo '<ul class="children" style="padding-left:15px;">';
                foreach($post1 as $key2 => $val2)
                {
                    echo '<li><a title='.$val2->post_title.' href='.$val2->guid.'>'.$val2->post_title.'</a></li>';
                }
                echo '</ul></div>';
            }

        }

    }

    echo "</ul>";
    echo "</li>";
}
echo '</ul>';
?>
</div>

so plz help me 所以请帮我

Have you checked you have set your DOCTYPE correctly? 您检查过是否正确设置了DOCTYPE? For Tiny accordion to work you need the following doctype, just add it at the top of your file. 为了使Tiny手风琴工作,您需要以下doctype,只需将其添加到文件顶部即可。

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>

Hey, maybe I'm just being dumb but shouldn't: 嘿,也许我只是傻了,但不应该:

echo '<li class="cat-item"><a title='.$val1->post_title.' href='.$val1->guid.'>'.$val1->post_title.'</a>';

be

echo '<li class="cat-item"><a title='.$val1->post_title.' href='.$val1->guid.'>'.$val1->post_title.'</a></li>';

I can see firefox being clever about things, but IE is often a little more strict about closing tags. 我可以看到firefox在事情上很聪明,但是IE在关闭标签方面通常要严格一些。 Hope that helps =] 希望有帮助=]

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

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