首页 \ 问答 \ 为什么jQuery在鼠标移动/悬停时切换不断变化(Why is jQuery toggle continually changing on mouse movement/hover)

为什么jQuery在鼠标移动/悬停时切换不断变化(Why is jQuery toggle continually changing on mouse movement/hover)

通过这里的答案,我刚刚得到了jQuery中的这些代码 -

$('.folder-items a').hover(function(){
   $(this).siblings('.file-hover').toggle();
});​

.folder-items a .folder-items在里面。 我希望能够悬停整个'li'而不仅仅是在实际的<a>上显示.file-hover div。

我已经在jsfiddle中创建了它 - http://jsfiddle.net/8Sefc/8/ - 但是当我的鼠标移动到li时,它显示/隐藏像疯了一样...

我认为这是我的CSS和显示:块; 宽度:100%; 李和李一个,但不能找出另一种方式来做到这一点...

想法?


I've just got this bit of code working in jQuery via an answer on here -

$('.folder-items a').hover(function(){
   $(this).siblings('.file-hover').toggle();
});​

the .folder-items a is within a li. I want to be able to hover the whole 'li' and not just on the actual <a> to show the .file-hover div.

I've created this in jsfiddle - http://jsfiddle.net/8Sefc/8/ - but when moving my mouse around the li it's showing/hiding like crazy...

I think it's something up with my CSS and display: block; width: 100%; of the li and li a but can't work out another way to do this...

Ideas?


原文:https://stackoverflow.com/questions/9344834
更新时间:2024-05-23 16:05

最满意答案

strcpy(t->buffer, file_name);

正在写一个未初始化的指针。 您需要为buffer分配内存。 如果您使用的是Posix兼容系统,最简单的方法是使用strdup

t->buffer = strdup(file_name);

否则,您需要分配内存然后单独复制

t->buffer = malloc(strlen(file_name)+1);
strcpy(t->buffer, file_name);

在任何一种情况下,当你为每个node释放内存时,你需要free(t->buffer)


strcpy(t->buffer, file_name);

is writing to an uninitialised pointer. You need to allocate memory for buffer. If you're on a Posix-compatible system, the easiest way to do this is by using strdup

t->buffer = strdup(file_name);

Otherwise, you need to allocate memory then copy separately

t->buffer = malloc(strlen(file_name)+1);
strcpy(t->buffer, file_name);

In either case, you'll need to free(t->buffer) when you free memory for each node

相关问答

更多
  • 你可以在内存中拥有平衡的树。 AVL树只是一种平衡树,还有其他树,例如红黑和2-3-4树。 所以,我不知道你在哪里想到平衡树不能存在于内存中,但如果我是你,我会重新思考。 而且,实际上,如果您愿意,也可以将AVL树放在磁盘上。 我怀疑,根据你的评论,你可能想到的是一个BTree,它就像一个二叉树,但每个节点可以拥有多个值,并且有两个以上的子节点,例如: root node -, | V +------+------+------+ | Val1 | Val2 ...
  • AVL树比其他树木(如红黑树或2-3棵树或仅仅是普通的BST)有其优点和缺点。 AVL树木: 优点: 简单。 相当容易编码和理解 额外存储:相当小,每个节点2位(存储+ 1,0,-1)。 还有一个技巧,您可以使用您孩子的单个位在每个节点使用1位。 查找常量(查看您最喜欢的分析书:Knuth等)是1.5(所以1.5 log)。 红黑树的常数为2(因此查找时为2 * log(n))。 缺点: 删除是昂贵的。 删除节点仍然是对数,但您可能必须“一直”旋转到树的根。 换句话说,一个更大的常数。 红黑树只需做1次旋转 ...
  • 我认为你在这些行中将垃圾字符串插入到数据结构中: for (int i = 1; i <= 10; ++i) t.insert(i+" "); " "的类型是const char * ,当你向它添加一个整数时,你得到另一个与原始指针偏移的const char * 。 因为字符串" "恰好存储在程序中字符串"Printing balance:"之前,所以当您执行该代码时,最终会生成指向"Printing balance:"字符串内各个位置的指针。 要在C ++中正确地将数字转换为字符串,您可以使用s ...
  • 不,它不是,因为节点5的子树高度相差超过1。 左子树为空(高度为0),右子树为7-8(因此其高度为2)。 No, it is not, because the subtrees of node 5 differ by more than 1 in height. The left subtree is empty (its height is 0) and the right subtree is 7-8 (so its height is 2).
  • 您的代码正在向上攀升。 考虑以下代码: if (this.getLeftChild() != null) { return this.getLeftChild().insert(node); } 并稍微修改它: if (this.getLeftChild() != null) { boolean b = this.getLeftChild().insert(node); // do something here return b; } 当代码从递归调用返回时,每次返回 ...
  • strcpy(t->buffer, file_name); 正在写一个未初始化的指针。 您需要为buffer分配内存。 如果您使用的是Posix兼容系统,最简单的方法是使用strdup t->buffer = strdup(file_name); 否则,您需要分配内存然后单独复制 t->buffer = malloc(strlen(file_name)+1); strcpy(t->buffer, file_name); 在任何一种情况下,当你为每个node释放内存时,你需要free(t->buffer ...
  • 轮流: localroot = temp; 您应该通过引用传递参数。 如果没有,实际参数不能改变,你会得到内存泄漏。 AVL :: insertRecursive中的nodeme也是如此。 in rotation: localroot = temp; You should pass parameter by reference. If not, the actual parameter can't be changed and you'll get memory leak. And so does no ...
  • 简单地说,是的 尝试查找现有实现的源代码,这将在未来帮助您。 Simply put, Yes Try finding the source code for an existing implementation, that should help you in the future.
  • 看看这段代码: destroyTree(root); if(root == NULL) std::cout << "destroyed" << std::endl; 可能你的destroyTree函数有这个原型: void destroyTree(nodeType *node); 问题是节点不能更新调用者的内存地址,但只能调用调用者指向的内容。 这意味着root永远不会更新,即它的内容不能更新为NULL。 要做到这一点,你需要一个类似这样的原型: void destroyTree ...
  • 插入后,您需要在树的所有方向上更新每个“父”的平衡因子,直到根; 所以这是O(log n)更新的最大值。 但是你只需要进行一次重组就可以将树恢复到它的不变量。 删除后,如插入,您必须在树上一直更新平衡因子; 所以它再次是O(log n)更新。 但是,与insert不同,您可能需要多次重组旋转才能将树恢复为不变量。 http://en.wikipedia.org/wiki/AVL_tree After an insertion, you need to update the balance factor of ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)