0
我試圖通過點擊'.sbSelector'將窗口向下滾動200px,如果單擊的元素(即'.sbSelector' )定位在距窗口高度小於200px處。如何獲得jQuery中的內部選擇器回調函數內的當前父選擇器的實例
$(document).on('click', '.sbSelector', function(){
var windowHeight = $(window).height();
var drpdwnOffsetTop = parseFloat($(this).offset().top - $(window).scrollTop());
if(parseFloat(windowHeight - drpdwnOffsetTop) < 200){
var temp = $(window).scrollTop() + 200;
$('html, body').animate({scrollTop: temp}, 500, function(){
**// How to get the instance of current '.sbSelector' here**
**// $(this) ll point to $(html,body), where as i need a reference to the current $('.sbSelector')**
});
}
});
我的查詢是如何才能獲得$(‘HTML,身體’)內當前的「.sbSelector」的一個實例。動畫回調函數。 Bcoz文檔中可能有許多'.sbSelector'元素,我想指向動畫回調中當前點擊的'.sbSelector'。
謝謝。有效。 – Manju
@Manju如果您發現我的回答對您有幫助,請將其標記爲已接受,以便幫助其他人。 – Daerik