Team:NCTU Formosa/source/head
From 2013.igem.org
(Difference between revisions)
Line 23: | Line 23: | ||
adjustStyle($(this).width()); | adjustStyle($(this).width()); | ||
}); | }); | ||
- | $(window).scroll(function () { | + | $(document).ready(function() { |
+ | |||
+ | //attach some code to the scroll event of the window object | ||
+ | //or whatever element(s) see http://docs.jquery.com/Selectors | ||
+ | $(window).scroll(function () { | ||
var height = $('body').height(); | var height = $('body').height(); | ||
var scrollTop = $('body').scrollTop(); | var scrollTop = $('body').scrollTop(); | ||
- | var opacity = | + | var opacity = 1; |
- | + | // do some math here, by placing some condition or formula | |
- | if(scrollTop > | + | if(scrollTop > 400) { |
- | opacity = 0; | + | opacity = 0.5; |
} | } | ||
+ | |||
+ | //set the opacity of div id="someDivId" | ||
$('#top-section').css('opacity', opacity); | $('#top-section').css('opacity', opacity); | ||
}); | }); | ||
+ | }); | ||
var lastId, | var lastId, | ||
topMenu = $("#toc"), | topMenu = $("#toc"), |
Revision as of 12:52, 30 August 2013