Я пытаюсь получить доступ к селектору объекта jQuery внутри закрытия ниже, так что мне не нужно указывать его и/или кэшировать. Если я заменил $ (". The_lead") на $ this, он не выполнит действия.jQuery Область доступа к селектору jQuery
Вызов плагин
$(".the_lead").scroll_lead({speedup: 400});
Блок
var $this = $(this);
$(window).scroll(function() {
var window_height = $(window).height();
var document_height = $(document).height();
var hide_lead;
var scrollTop = $(window).scrollTop();
console.log($this);
if(!hide_lead){
if(scrollTop>(document_height/2)){
$(".the_lead").slideDown(options.speedup);
}else{
$(".the_lead").slideUp(500,function(){
$(".the_lead").hide();
});}
}
$('#hide_lead').click(function(e){
//$(".the_lead").parent().parents('div').hide();
hide_lead = true;
e.preventDefault();
});
});
консоли Выход за $ (это):
[selector: ".the_lead", context: document, constructor: function, init: function, selector: ""…]
context: #document
length: 0
selector: ".the_lead"
__proto__: Object[0]
спасибо. Я решил проблему, с которой я столкнулся с http://stackoverflow.com/questions/5477394/getting-initial-selector-inside-jquery-plugin ответ от BGerrissen – Codex73