脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-ѧϰJQuery - 11,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。
2. 效果及持续性
我们在文章大部分用“Read more”来缩短文章读取速度。
这是我们就要用到显示和隐藏功能。
例如:
Fourscore and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the PRoposITion that all men are created equal.
read moreThe brave men, living and dead, who struggled here have consecrated it, far above our poor power to add or detract. The world will liTTLe note, nor long remember, what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.
It is rather for us to be here dedicated to the great task remaining before us―that From these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion―that we here highly resolve that these dead shall not have died in vain―that this nation, under God, shall have a new birth of freedom and that government of the PEople, by the people, for the people, shall not perish from the earth.
但我们点击“read more”时候会显示隐藏的内容。
js代码
$('p').eq(1).show();隐藏时
$('p').eq(1).hide();
(1) 渐进效果
显示
$('p').eq(1).fadeIn();隐藏
$('p').eq(1).fadeOut();
显示
$('p').eq(1).slideUp()隐藏
$('p').eq(1).slideDown()
当“段落”隐藏时,执行此方法时就显示“段落”;反之相同。
附:
chapter4-2.htML
Abraham Lincoln's Gettysburg Address <script src="jquery-1.10.2.js"></script> <script src="chapter04-2.js"></script>
Abraham Lincoln's Gettysburg Address
Text Size
Fourscore and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field as a final resting-place for those who here gave their lives that the nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, we cannot consecrate, we cannot hallow, this ground.
read moreThe brave men, living and dead, who struggled here have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember, what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.
It is rather for us to be here dedicated to the great task remaining before us―that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion―that we here highly resolve that these dead shall not have died in vain―that this nation, under God, shall have a new birth of freedom and that government of the people, by the people, for the people, shall not perish from the earth.
@charset "utf-8"; /* CSS Document */ /*************************************** Default Styles ************************************** */ html, body { margin: 0; padding: 0; } body { font: 62.5% Verdana, Helvetica, Arial, sans-serif; color: #000; background: #fff; } #container { font-Size: 1.2em; margin: 10px 2em; } h1 { font-size: 2.5em; margin-bottom: 0; } h2 { font-size: 1.3em; margin-bottom: .5em; } h3 { font-size: 1.1em; margin-bottom: 0; } a { color: #06581f; } /* Chapter Styles */ #switcher { width: 300px; padding: .5em; border: 1px solid #777; } .label { width: 130px; margin: .5em 0; cursor: pointer; }
$(document).ready(function() { $('p').eq(1).hide(); $('#switcher').click(function() { $('a.more').show(); }); $('a.more').click(function() { //$('p').eq(1).show(); //$('p').eq(1).fadeIn(); //$('p').eq(1).slideUp(800); $('p').eq(1).slideToggle('slow'); $(this).hide(); }); });
觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!
以上是脚本宝典为你收集整理的javascript代码实例教程-ѧϰJQuery - 11全部内容,希望文章能够帮你解决javascript代码实例教程-ѧϰJQuery - 11所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。