【发布时间】:2012-03-24 02:34:22
【问题描述】:
我有 2 个 div 需要来回切换显示和不显示。这是我当前的 jQuery 代码
$(document).ready(function(){
$('a:link').click(function(){
$(".surveycontainer").toggle();
$("#check").toggle();
});
});
注意 #check 在通过 CSS 加载的页面时隐藏,因此该脚本表示,当单击链接时,每个链接都会被切换,从而使“surveycontainer”div 消失,“check”div 出现,反之亦然。
当在调查容器(包含链接)中调用 RSS 提要时,该脚本可以正常工作,并且在单击每个 div 时都会切换。将普通链接放置在 div 中时会出现问题,单击时“surveycontainer”被隐藏但“检查”未显示!
调查容器代码
<div class="surveycontainer" align="left">
<?php
// OFFERS
//Right here is a script that defines $country_code ("US" is what is called when the problem occurs)
<?php if($country_code=="US"): ?>
<a href="http://www.google.com" target="_blank">Yahoo</a>
<?php else: ?>
//Calls a RSS feed containing links here
</div>
<?php endif; ?>
如您所见,如果 $country_code 等于“US”,则会在新窗口中调用 Google 链接。
由于某些原因,当国家代码不等于 US 并且数据是从 RSS 提要中提取时,上面的 jQuery 脚本会在单击链接时切换每个 div。但是,当使用 Google 链接并单击时,只有“surveycontainer”div 被隐藏,“check”不显示。
我迫切需要解决这个问题!任何帮助都非常感谢,谢谢!
【问题讨论】: