如何使用jquery展开折叠切换div图层

时间:2011-10-27 14:28:51

标签: javascript jquery css expand collapse

我尝试使用以下教程How to expand collapse (toggle) div layer using jQuery

它在index.html文件中工作正常,但我想将代码添加到以下模板

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset={$charset}" />
<title>{$companyname} - {$pagetitle}{if $kbarticle.title} - {$kbarticle.title}{/if}</title>
{if $systemurl}<base href="{$systemurl}" />
{/if}
{if $LANG.stylearabic == 'stylearabic'}
<link rel="stylesheet" type="text/css" href="templates/{$template}/style-arabic.css" />
<link rel="stylesheet" type="text/css" href="ads/ads.css" />    
{else}
<link rel="stylesheet" type="text/css" href="templates/{$template}/style.css" />
<link rel="stylesheet" type="text/css" href="ads/ads.css" />    
{/if}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
  jQuery(".content").hide();
  //toggle the componenet with class msg_body
  jQuery(".heading").click(function()
  {
    jQuery(this).next(".content").slideToggle(500);
  });
});
</script>
<script type="text/javascript" src="includes/jscript/jquery.js"></script>

{if $livehelpjs}{$livehelpjs}
{/if}</head>
<body>
<div class="layer1">
<p class="heading"><img border="0" src="ads/Y-bar.png" width="500" height="30"></p>
<div class="content"><img border="0" src="ads/big.jpg" width="500" height="500">
</div>
</div>
<div id="top_container">
  <div id="top">
    <div id="company_title">{$companyname}</div>
    <div id="welcome_box">{if $loggedin}{$LANG.welcomeback}, <strong>{$loggedinuser.firstname}</strong>&nbsp;&nbsp;&nbsp;<img src="templates/{$template}/images/icons/details.gif" alt="{$LANG.clientareanavdetails}" width="16" height="16" border="0" class="absmiddle" /> <a href="clientarea.php?action=details" title="{$LANG.clientareanavdetails}"><strong>{$LANG.clientareanavdetails}</strong></a>&nbsp;&nbsp;&nbsp;<img src="templates/{$template}/images/icons/logout.gif" alt="{$LANG.logouttitle}" width="16" height="16" border="0" class="absmiddle" /> <a href="logout.php" title="Logout"><strong>{$LANG.logouttitle}</strong></a>{else}{$LANG.please} <a href="clientarea.php" title="{$LANG.loginbutton}"><strong>{$LANG.loginbutton}</strong></a> {$LANG.or} <a href="register.php" title="{$LANG.clientregistertitle}"><strong>{$LANG.clientregistertitle}</strong></a>{/if}</div>
  </div>
</div>
<div id="content_container">
{if $loggedin}
  <div id="top_menu">
    <ul>
      <li><a href="clientarea.php" title="{$LANG.clientareanavhome}">{$LANG.clientareanavhome}</a></li>
      <li><a href="clientarea.php?action=details" title="{$LANG.clientareanavdetails}">{$LANG.clientareanavdetails}</a></li>
      <li><a href="clientarea.php?action=products" title="{$LANG.clientareanavservices}">{$LANG.clientareanavservices}</a></li>
      <li><a href="clientarea.php?action=domains" title="{$LANG.clientareanavdomains}">{$LANG.clientareanavdomains}</a></li>
      <li><a href="clientarea.php?action=quotes" title="{$LANG.quotestitle}">{$LANG.quotestitle}</a></li>
      <li><a href="clientarea.php?action=invoices" title="{$LANG.invoices}">{$LANG.invoices}</a></li>
      <li><a href="supporttickets.php" title="{$LANG.clientareanavsupporttickets}">{$LANG.clientareanavsupporttickets}</a></li>
      <li><a href="affiliates.php" title="{$LANG.affiliatestitle}">{$LANG.affiliatestitle}</a></li>
      <li><a href="clientarea.php?action=emails" title="{$LANG.clientareaemails}">{$LANG.clientareaemails}</a></li>
    </ul>
    <div class="clear"></div>
  </div>
{/if}
  <div id="content_left">
    <h1>{$pagetitle}</h1>
    <p class="breadcrumb">{$breadcrumbnav}</p>

我在IE8上遇到以下错误,也无法在任何浏览器中使用

Webpage error details

Message: Expected '{'
Line: 11
Char: 35
Code: 0

我怎样才能做到这一点?

感谢

1 个答案:

答案 0 :(得分:0)

以下教程适用于模板引擎代码 expandable collapsible toggle pane jquery