我正在尝试使用外部链接打开手风琴。实际上页面上有三个主要的手风琴(关于、结果、联系方式)
并且有一个包含项目(关于,结果,联系方式)的菜单栏。
我想要的是当我点击关于菜单项时它应该打开关于手风琴
下面是jquery代码
$(function() {
$( "#accordion" ).accordion({
collapsible: true,
autoHeight: false ,
active: false,
navigation:true,
});
$(".exlnk").click(function(event){
window.location.hash=this.hash;
});
});
下面是html菜单栏代码:
<div id="navmenu" style='z-index:9999;'>
<ul>
<li><a href="#anchor_about" class="anchor_about">About</a></li>
<li><a href="#" >Results</a></li>
<li><a href="#" class ="anchor_contact">Contact</a></li>
</ul>
</div>
以下是外部链接的jquery代码
<script>
$(document).ready(function(){
$('a.anchor_about').click(function(){
$("#accordion").accordion("activate", '<?php echo $_GET['id']; ?>');
return false;
});
});
</script>
但它不工作..:(
有人知道吗?提前致谢
编辑1
<script>
$("#navmenu ul").children("li").click(function()
{
$("#accordion").accordion("activate", <?php echo (int)$_GET['id']; ?>);
});
编辑2
下面是手风琴代码
<div class="demo">
<div id="accordion"> <!--- main accordion 1 demo-->
<h3><a href="#anchor_home"></a></h3>
<div id="accordion1" style="margin-bottom:17px;" >
<h1><a href="#" ></a></h1>
<div id="content_our_offer" > <!--- sub accordion 1 demo-->
<?php $page_id=1742;?>
<?php get_page( $page_id ) ;
$page_data = get_page( $page_id );
echo '<h3>'. $page_data->post_title .'</h3>';// echo the title
echo apply_filters('the_content', $page_data->post_content); ?>
</div>
<div style="margin-top:20px;"> <!--- sub accordion 2 demo-->
<h2 ><a href="#" ></a></h2> </div>
<div id="content_our_offer" >
<?php $page_id=1742;?>
<?php get_page( $page_id ) ;
$page_data = get_page( $page_id );
echo '<h3>'. $page_data->post_title .'</h3>';// echo the title
echo apply_filters('the_content', $page_data->post_content); ?>
</div>
</div>
<div style="margin-top:20px;">
<h6><a class="exlnk" href="#about" title="About" ></a></h6> </div> <!--- main accordion 2 demo-->
<div id="id_ourresults">
<?php
$directory = 'our_results';
try {
// Styling for images
foreach ( new DirectoryIterator("../" . $directory) as $item ) {
if ($item->isFile()) {
echo "<div class=\"expand_image\">";
$path = "/" . $directory . "/" . $item;
echo "<img src=\"" . $path . "\" width=861 height=443 />";
echo "</div>";
}
}
}
catch(Exception $e) {
echo 'No images found for this player.<br />';
}
?>
</div>
<div style="margin-top:20px;">
<h4><a href="#anchor_contact"></a></h4> </div> <!--- main accordion 3 demo-->
<div id="id_contactus">
<?php $page_id=1791 ;?>
<?php get_page( $page_id ) ;
$page_data = get_page( $page_id );
echo '<h3>'. $page_data->post_title .'</h3>';// echo the title
echo apply_filters('the_content', $page_data->post_content); ?>
</div>
</div>
</div><!-- End demo -->