Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery动画队列&;此函数_Jquery_Html_Animation - Fatal编程技术网

jQuery动画队列&;此函数

jQuery动画队列&;此函数,jquery,html,animation,Jquery,Html,Animation,所以我有多篇文章: <article id="product-box"> <header id="product-head"><!--thumbnail--></header> <footer id="product-foot"><span class="product-element">Product Title</span></footer> </article> 然

所以我有多篇文章:

<article id="product-box">
    <header id="product-head"><!--thumbnail--></header>
    <footer id="product-foot"><span class="product-element">Product Title</span></footer>
</article>
然而,由于我有多篇文章,所以效果会对每一篇都有效,但我希望它只对我正在浏览的那篇文章有效。 也就是说,如果我将鼠标悬停在#product box元素上,我希望该元素中的#product foot子元素具有动画效果。我想知道是否有办法做到这一点?

$(“#产品>#产品盒”).mouseover(函数(){

以上代码仅适用于单篇文章,我是指第一篇文章。

要使您的代码适用于所有文章,您可以这样做

$("[id=product-box]").mouseover(   //..this makes code work on all product box elements
参考此

因此,要使当前产品盒上的子对象具有动画效果,您可以这样做

$("[id=product-box]").mouseover(function(){
      $(this).children("#product-foot").stop().animate({'margin-left': '20px'},500);});

希望这有帮助!!…

你是说你有多个元素具有相同的ID吗?如果是,不要这样做。元素ID必须是唯一的。每个人都这样做吗?我认为这将是一种简化的方法。因此,我必须为每个元素创建一个新的ID?例如
product-box1
product-box2
…等等?不,你可以使用class.Like:''。然后用$(“.product box”)来称呼它。我明白了,谢谢你的帮助。我一直在找这样的东西,非常感谢!
$("[id=product-box]").mouseover(function(){
      $(this).children("#product-foot").stop().animate({'margin-left': '20px'},500);});