Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Mirko Blejic
Courses Plus Student 37 PointsJavascript not working
Hello,
I need your help guys, this Javascript is loading on page but not working (it is working in HTML file)...
What should I do?
var timer = 0;
function recheck() {
var window_top = $(this).scrollTop();
var window_height = $(this).height();
var view_port_s = window_top;
var view_port_e = window_top + window_height;
if ( timer ) {
clearTimeout( timer );
}
$('.flyin').each(function(){
var block = $(this);
var block_top = block.offset().top;
var block_height = block.height();
if ( block_top < view_port_e ) {
timer = setTimeout(function(){
block.addClass('show-block');
},100);
} else {
timer = setTimeout(function(){
block.removeClass('show-block');
},100);
}
});
}
$(function(){
$(window).scroll(function(){
recheck();
});
$(window).resize(function(){
recheck();
});
recheck();
});
1 Answer

Stephen O'Connor
22,291 PointsIs this within a WordPress theme? If so have you used the noconflict method for using jQuery with WordPress?
(function($) {
// Your code here
})(jQuery);
Mirko Blejic
Courses Plus Student 37 PointsMirko Blejic
Courses Plus Student 37 PointsThanks