当鼠标光标只显示在一个元素上时,为什么要使用所有元素?
Why are utilized all the elements when the mouse cursor is shown on only one element?
我有一个带标题的下拉条纹。当鼠标光标仅显示在一个元素上时,所有元素都变为活动状态。为什么会发生这种情况,以及如何使只有一个帖子是活跃的。例如:http://beardhouse.com.ua/
//post-description slide
$(".contant").hover(function(){
$(".post-description").css({
'left': '-5px',
'-webkit-transition-duration': '0.3s',
'-moz-transition-duration': '0.3s',
'-o-transition-duration': '0.3s',
'transition-duration': '0.3s',
});
},function(){
$(".post-description").css({
'left': '-120px',
'-webkit-transition-duration': '0.3s',
'-moz-transition-duration': '0.3s',
'-o-transition-duration': '0.3s',
'transition-duration': '0.3s'
});
});
==================================================================================
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<div class="col-lg-3">
<div class="stripe_part"><img src="http://beardhouse.com.ua/wp-content/themes/arbion/images/stripe_left.png"></div>
<div class="contant">
<div class="post-description"><a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></div>
<a href="<?php the_permalink(); ?>"><img src="<?php echo first_image() ?>"title="<?php the_title(); ?>" /></a></div> <!-- /take a first image from the post -->
</div>
<?php endwhile; ?>
<?php endif; ?>
.post-description
将匹配所有具有类后描述的元素。您只希望对悬停在其上的项的子元素执行效果。所以把选择器改成:
$(this).find(".post-description")
那么你的整个代码就是:
//post-description slide
$(".contant").hover(function(){
$(this).find(".post-description").css({
'left': '-5px',
'-webkit-transition-duration': '0.3s',
'-moz-transition-duration': '0.3s',
'-o-transition-duration': '0.3s',
'transition-duration': '0.3s',
});
},function(){
$(this).find(".post-description").css({
'left': '-120px',
'-webkit-transition-duration': '0.3s',
'-moz-transition-duration': '0.3s',
'-o-transition-duration': '0.3s',
'transition-duration': '0.3s'
});
});
$(".contant").hover(function(){
$(this).find(".post-description").css({
'left': '-5px',
'-webkit-transition-duration': '0.3s',
'-moz-transition-duration': '0.3s',
'-o-transition-duration': '0.3s',
'transition-duration': '0.3s',
});
},function(){
$(this).find(".post-description").css({
'left': '-120px',
'-webkit-transition-duration': '0.3s',
'-moz-transition-duration': '0.3s',
'-o-transition-duration': '0.3s',
'transition-duration': '0.3s'
});
});
相关文章:
- 为什么元素的宽度在页面加载之后和那一刻之后不同
- 为什么在这个网站上不能通过JS访问元素
- 为什么我在Internet Explorer上看不到html元素
- 为什么可以't PHP查找可以使用JS或jQuery访问的元素
- 为什么这只是迭代 HTMLCollection 的奇怪元素
- 为什么样式属性不适用于使用DOMParser创建的元素
- 为什么用javascript覆盖2D数组的元素
- 为什么不是't my元素:使用变量而不是字符串时包含(变量)功?jquery
- 为什么表单元素不应命名为submit
- 为什么不't React缓存子组件的html元素
- 为什么body元素上的onclick事件不起作用
- 为什么不是't html<对象>元素响应鼠标事件
- 为什么JQueryshow()函数只对带有选择器的一个(而不是所有)元素起作用
- 为什么Bootstrap typeahead不适用于具有相同ID的输入元素
- JQuery可以'找不到我的元素.为什么?
- Marionette CompositeView调用了从属于CompositeView的集合添加的每个元素..为什么?
- 使用nodeList "childNodes"的元素.为什么容器没有被移除?
- 在javascript中使用多个数字来访问数组's元素:为什么这样做呢?
- 我尝试拖放一个元素.为什么我的代码不能正常工作?
- JQuery找不到JavaScript找到的元素.为什么?