var hide_text = "hide"; function toggle(selector, show_text) { if ($(selector).text() == show_text) { $(selector).parent().siblings('pre').fadeIn(1000); $(selector).text(hide_text); } else { $(selector).parent().siblings('pre').hide(); $(selector).text(show_text); } } //there! fade in functionality cus everybody wants some animation! /*tiles = $("p").fadeOut(); $(window).scroll(function(d,h) { tiles.each(function(i) { a = $(this).offset().top + $(this).height(); b = $(window).scrollTop() + $(window).height(); if (a < b) $(this).fadeIn(); }); }); $(document).ready(function(){ $(window).scroll(function(){ alert(2); }) }) function init(){ tiles = $("section").css("visibility","hidden"); } $(window).scroll(function(d,h) { tiles.each(function(i) { a = $(this).offset().top + $(this).height(); b = $(window).scrollTop() + $(window).height(); if (a < b) { $(this).css("visibility","visible"); $(this).fadeIn(1000); } }); })*/ function add_toggle(id) { $(document).ready(function() { $(".more_"+id).toggle(); toggle_text(".toggle_"+id); }); $(function() { $(".toggle_"+id).click(function() { $(".more_"+id).toggle(); toggle_text(".toggle_"+id); }); }); }