Jquery Ajax beforeSend loading animation
Jquery Ajax beforeSend loading animation
大家好,我的 ajax 加载动画有一个问题。问题是当我悬停在任何图像上时,加载动画在所有图像下处于活动状态。
像这个小提琴
我想在悬停第一张图像时制作,然后.ajax-loading
仅为该图像激活。 如果我悬停第二张图像,那么.ajax-loading
仅对第二张图像扩展处于活动状态。
有人可以在这里帮助我吗?.CSS
.ajax-loading {
transition: all 0.3s;
opacity: 0;
z-index: -1;
}
.ajax-loading.active {
opacity: 1;
z-index: 100;
}
和阿贾克斯
$(document).ready(function () {
function showProfileTooltip(e, id) {
//send id & get info from get_profile.php
$.ajax({
url: '/echo/html/',
data: {
html: response,
delay: 0
},
method: 'post',
beforeSend: function() {
$('.ajax-loading').addClass('active');
},
success: function (returnHtml) {
e.find('.user-container').empty().html(returnHtml).promise().done(function () {
$('.the-container').addClass('loaded');
});
}
}).complete(function() {
$('.ajax-loading').removeClass('active');
});
}
function hideProfileTooltip() {
$('.the-container').removeClass('loaded');
}
$('.the-container').hover(function (e) {
var id = $(this).find('.summary').attr('data-id');
showProfileTooltip($(this), id);
}, function () {
hideProfileTooltip();
});
});
问题是 beforeSend
函数激活了类active
具有类.ajax-loading
的所有元素。
由于您将接收悬停的 jQuery 对象传递给函数,因此您可以利用这一点并将类active
仅添加到其下具有类.ajax-loading
的元素。
beforeSend: function() {
$('.ajax-loading',e).addClass('active');// Note the ,e that I added
},
小提琴
希望对您有所帮助。
相关文章:
- paper.js animation along a path
- Jquery animation/fadeIn/fadeOut
- Animation cuts off multiple lines of text in <p>
- jquery animation.scrollTop()在mdl链接中不起作用
- JQuery mobile 1.3.2 : $.mobile.loading 停止在 iOS 上工作
- javascript lazy loading in android hybrid app
- Stop ::-webkit-progress-value animation
- 将 JQuery Animation 转换为 Javascript/CSS3
- Jquery UI Not Loading
- blueimp库调用loading.gif导致错误
- d3 animation wordCloud flyin
- Google Maps Javascript API is not loading
- JavaScript not loading?
- Angular Animation类中Greensock JavaScript的非平滑tweening
- AngularJS location.hash animation
- Geocoding和Animation.drop与超时不兼容
- Jquery Ajax beforeSend loading animation
- 函数jQuery.animation()运行了两次行,但不起作用
- CSS animation and Jquery2
- Javascript loading bar