# Code snippet for Web Programming at 2012/10/8, # slide at http://zoro.ee.ncku.edu.tw/wp2012/res/04-javascript.pdf var sum = 0; for ( i = 1; i <= 10; ++i ) { sum += i; } # accumulate from one to ten # DOM object for output
Div
# another DOM object document.getElementById('foo').value=sum; # show the result jQuery('.foo').css('color','red'); # change text color jQuery('.foo').animate({'margin-left': '100px'}, 2000, function(){/*animation completed*/}); # handle event jQuery('.foo').click(function(){ jQuery(this).css('color','green'); jQuery(this).animate({'margin-left':'100px'},2000,function(){ jQuery(this).css('padding-top','100px'); }); }); # vi:nowrap:sw=4:ts=4