3 javascript jquery html5 this jquery-waypoints
$(this)属性与waypoints.js无关.
我的Javascript:
$('.dipper').waypoint(function() {
$(this).addClass('test');
}, { offset: '100%' });
Run Code Online (Sandbox Code Playgroud)
奇怪的是,本守则在我的网站上运作良好:
$('.dipper').waypoint(function() {
$('.dipper').addClass('test');
}, { offset: '100%' });
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我使用.dipper而不是$(this).您可以在我的网站上查看:http://www.sq-media.de/weboptimierungen/rehfeld
waypoint方法不使用与父jQuery对象相同的上下文运行.如果您需要此行为,则可以使用each迭代.dipper元素:
$('.dipper').each(function() {
var $this = $(this);
$this.waypoint(function() {
$this.addClass('test');
}, { offset: '100%' });
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
410 次 |
| 最近记录: |