我想在鼠标悬停时显示数据,但是,我对 jQuery 的了解很弱,我不知道如何在悬停时通过它获取数据。到目前为止,这是我的功能:
function test_contact_group($id){
$results = $this
->Contact
->ContactsContactGroup
->find('all', array('conditions'=> array('ContactsContactGroup.contact_id'=>$id,)));
$this->set('results',$results);
}
我的观点是:
<div class="firsttable">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr class="heading">
<td><?php echo __l('Group Name');?></td>
</tr>
</thead>
<tbody>
<?php foreach ($results as $results){?>
<tr>
<td>
<?php echo $results['ContactGroup']['name']?>
</td>
</tr>
<?php }?>
</tbody>
</table>
</div>
获取数据的链接是
<?php echo $this->Manager->link($records['ContactGroup']['name'],array('action'=> 'test_contact_group', $records['Contact']['contact_id']));?>
链接的 HTML 为
<a href="/contacts/test_contact_group/78">default</a>
我想通过悬停时的此链接显示数据,我该怎么做,请帮助我做到这一点,任何人都可以提供帮助,我们将不胜感激,提前致谢
我在链接上传递的参数是
$records['Contact']['contact_id'])
最佳答案
由于您的问题没有定义具体细节,我将为您提供 jQuery 库,可以引导您解决问题
有几种解决方案,一种是将数据已经放入html中,但用CSS隐藏。悬停时,您可以切换该元素的可见性。为此请查看 Jquery Effects其中涵盖了以下内容:显示、隐藏、切换、淡入、淡出、淡入淡出等。
如果您不是在寻找静态加载的内容并且喜欢在悬停时检索信息,那么您应该查看 Jquery ajax 中的任何一个功能例如:获取、发布或加载
关于javascript - 如何在悬停时显示数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15271592/