日期:2014-05-16 浏览次数:20419 次
学习javascript,实现两个功能:
?
?
参考链接:缓动效果参考文章:JavaScript html js Tween类型
?
?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title></title> <link rel="stylesheet" type="text/css" href="css/hidden.css" media="all" /> <script src="js/hidden.js" type="text/javascript" ></script> </head> <body> <div id="wrapper"> <div class="contents"> <div class="content"> <h1>Structuring our XHTML</h1> <p>There are plenty of reasons why you might feel the urge to wax verbose on your website's front page: to prevent your users from having to click through to a new page to find your information, to avoid having to reload the page, or even to improve your front page's SEO. But just because your front page is text-heavy doesn't mean it all needs to be visible at once.Today's tutorial will show you how to hide away extra bits of content using CSS and JavaScript, to be revealed at the click of a button. This is a great technique, because displaying the additional content doesn't require a refresh or navigation to a new page and all your content is still visible to search engine bots that don't pay any attention to CSS or JavaScript.</p> <p>We'll start with structuring our XHTML appropriately:</p> <div class="show">show more.</div> <div class="hidden" style="display:none"> <p>There are three things of importance here: the "show" anchor, the "hide" anchor, and our "hidden" div. Each has been given an ID and a class. The IDs are used by our JavaScript to locate and style the items appropriately. I'm then using the classes to set our "default" CSS. Technically you could just use the IDs the set that CSS as well, but if you wanted more than one hidden section on your page, that could get messy.</p> <p>You'll notice in the code above that all of our IDs are fairly similar. This is a trick I'm using to simplify our JavaScript, as you'll see later on down the road, so I suggest doing something similar. The class names have no relationship to the JavaScript whatsoever, and could really be whatever you wanted them to be.</p> </div> </div> <div class="content"> <h1>Structuring our XHTML</h1> <p>There are plenty of reasons why you might feel the urge to wax verbose on your website's front page: to prevent your users from having to click through to a new page to find your information, to avoid having to reload the page, or even to improve your front page's SEO. But just because your front page is text-heavy doesn't mean it all needs to be visible at once.Today's tutorial will show you how to hide away extra bits of content using CSS and JavaScript, to be revealed at the click of a button. This is a great technique, because displaying the additional content doesn't require a refresh or navigation to a new page and all your content is still visible to search engine bots that don't pay any attention to CSS or JavaScript.</p> <p>We'll start with structuring our XHTML appropriately:</p> <div class="show">show more.</div> <div class="hidden" style="display:none"> <p>There are three things of importance here: the "show" anchor, the "hide" anchor, and our "hidden" div. Each has been given an ID and a class. The IDs are used by our JavaScript to locate and style the items appropriately. I'm then using the classes