Javascript Don';不要让手风琴与js一起工作

Javascript Don';不要让手风琴与js一起工作,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我没有让手风琴工作: 我通过php函数使用一个短代码将其插入我的页面: // [container] function accordion($atts, $content=null, $code) { extract(shortcode_atts(array( 'open' => '1', 'title' => 'Title' ), $atts)); if (!preg_match_all("/(.?)\[(accordion-item)\b(.*?)(?:(\/

我没有让手风琴工作:

我通过php函数使用一个短代码将其插入我的页面:

// [container]
function accordion($atts, $content=null, $code) {

extract(shortcode_atts(array(
    'open' => '1',
    'title' => 'Title'
), $atts));

if (!preg_match_all("/(.?)\[(accordion-item)\b(.*?)(?:(\/))?\](?:(.+?)\[\/accordion-item\])?(.?)/s", $content, $matches)) {
    return do_shortcode($content);
} 
else {
    $output = '';
    for($i = 0; $i < count($matches[0]); $i++) {
        $matches[3][$i] = shortcode_parse_atts($matches[3][$i]);

        $output .= '<div class="accordion-title"><a href="#">' . $matches[3][$i]['title'] . '</a></div><div class="accordion-inner">' . do_shortcode(trim($matches[5][$i])) .'</div>';
    }
    return '<h3 class="accordion_h3">'.$title.'</h3><div class="accordion" rel="'.$open.'">' . $output . '</div>';

}   
/[容器]
函数accordion($atts,$content=null,$code){
提取(短码)附件(数组)(
“打开”=>“1”,
“标题”=>“标题”
)美元(附件);;
如果(!preg\u match\u all(“/(.?)\[(手风琴项目)\b(.*?(:(\/))?\](?:(.+?)\[\/手风琴项目\])?(.?)/s“,$content,$matches)){
返回do_短代码($content);
} 
否则{
$output='';
对于($i=0;$i

}`

您可能缺少这两个文件-markerclusterer.js和favico.js(404错误),因此这些错误会阻塞您的手风琴。

然后您将代码包装到
jQuery(函数($){…})
,因为这看起来像Wordpress?Jep它的Wordpress在这条语句中:
jQuery(document).ready(函数($){…})我认为应该在jquery脚本之后包含ui脚本。另外,你还没有关闭一些手风琴内部分区^^^他说,jQuery用户界面追求jQuery,但Wordpress不应该有这个问题,因为它应该自己弄清楚,如果你使用wp_enque_script正确地包含脚本,那么有大量优秀的Wordpress插件可供添加。您可以使用其中的一个,也可以查看他们的一些代码以了解其工作原理。在页面加载时打开浏览器控制台(对于Firefox浏览器,Firebug是一个不错的选择),您可以在那里看到您的所有ui错误。请确保打开控制台,然后加载页面
/*content accordion*/
$('.accordion').each(function(){
    var acc = $(this).attr("rel") * 2;
    $(this).find('.accordion-inner:nth-child(' + acc + ')').show();
    $(this).find('.accordion-inner:nth-child(' + acc + ')').prev().addClass("active");
});

$('.accordion .accordion-title').click(function() {
    if($(this).next().is(':hidden')) {
        $(this).parent().find('.accordion-title').removeClass('active').next().slideUp(200);
        $(this).toggleClass('active').next().slideDown(200);
    } else {
        $(this).parent().find('.accordion-title').removeClass('active').next().slideUp(200);
    }
    return false;
});
// [container]
function accordion($atts, $content=null, $code) {

extract(shortcode_atts(array(
    'open' => '1',
    'title' => 'Title'
), $atts));

if (!preg_match_all("/(.?)\[(accordion-item)\b(.*?)(?:(\/))?\](?:(.+?)\[\/accordion-item\])?(.?)/s", $content, $matches)) {
    return do_shortcode($content);
} 
else {
    $output = '';
    for($i = 0; $i < count($matches[0]); $i++) {
        $matches[3][$i] = shortcode_parse_atts($matches[3][$i]);

        $output .= '<div class="accordion-title"><a href="#">' . $matches[3][$i]['title'] . '</a></div><div class="accordion-inner">' . do_shortcode(trim($matches[5][$i])) .'</div>';
    }
    return '<h3 class="accordion_h3">'.$title.'</h3><div class="accordion" rel="'.$open.'">' . $output . '</div>';

}