Learning JQuery-11

Source: Internet
Author: User

2. effect and continuity

In most articles, we use "Read more" to speed up reading.

We need to use the display and hide functions.

For example:

Abraham Lincoln's Gettysburg AddressText Size Default Bigger Smaller

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 more

The 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 injection to that cause for which they gave the last full measure of injection- 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.


However, when we click "read more", the hidden content is displayed.

Js Code

$('p').eq(1).show();
Hide

$('p').eq(1).hide();

Can I add other effects when displaying or hiding them?

(1) Progressive Effect
Display

$('p').eq(1).fadeIn();
Hide
$('p').eq(1).fadeOut();

(2) sliding effect

Display

$('p').eq(1).slideUp()
Hide
$('p').eq(1).slideDown()

There is also a useful method in this effect: slideToggel ().

When "paragraph" is hidden, "paragraph" is displayed when this method is executed; otherwise, it is the same.


Appendix:

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        Default        Bigger        Smaller                    

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 more

The 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.


Chapter04.css

@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;}

Chapter04-2.js

$(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();    });});




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.