jQuery check if element exists
This question already has an answer here:
从...开始
if (!jQuery('.fixit').length) return;
if ($('.fixit').length) {
var el = jQuery('.fixit'),
offset = el.offset(),
elHeight = el.height(),
scrollTop = jQuery(window).scrollTop()
if (((offset.top + 400) < scrollTop - el.height())) {
el.addClass('fixedElement');
}
if (scrollTop === 0) {
el.removeClass('fixedElement');
}
}
链接地址: http://www.djcxy.com/p/83692.html
上一篇: 如何检查jQuery的FIND结果
下一篇: jQuery检查元素是否存在