好的,我在这里难过.我有一个由表组成的控件.我允许用户单击底行中的超链接直接转到关联的视图.
另一方面,用户可以点击表格内的任何其他位置并进行选择.此选择激活工具栏,允许用户对所选项目执行某些任务.如果用户再次单击所选项目,我想以编程方式单击超链接.但是,当我以编程方式单击超链接运行jQuery时,我不断收到"Out of stack space"错误.我完全知道click事件是递归调用的,但我不知道如何防止它!这是我的代码......
<head runat="server">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<style>
.mouseOver, .mouseOut, .selected
{
width: 120px;
height: 120px;
text-align: center;
vertical-align: top;
display: inline-block;
margin: 5px;
cursor: pointer;
}
.mouseOver
{
border: solid thin #99defd;
background: #e9f8fe;
}
.mouseOut
{
border: solid thin White;
}
.selected
{
border: solid thin #e0a403;
background: #f8f4de;
}
</style>
<script>
(function($) {
$(document).ready(function() {
var $items = $('.mouseOut');
$items.mouseenter(function() {
if ($(this).attr('class') != 'selected')
$(this).attr('class', 'mouseOver');
});
$items.mouseleave(function() {
if ($(this).attr('class') != 'selected') …Run Code Online (Sandbox Code Playgroud)