Learning JQuery-10

Source: Internet
Author: User

Chapter 4 Styling and Animating

1. Use inline attributes to modify CSS

We know that HTML reads various css values during onload.

Can we change the css value in subsequent operations?

The answer is yes! Otherwise, we won't see so many different effects in the previous chapters.

So what is the CSS value controlled by jQuery through that method?

css()
JQuery uses this method to retrieve or set css values.

After "css" is typed in DW, the prompt is as follows:


(1) Use ing, that is, K-V

(2) attribute name

(3) attribute name and index value

(4) attribute name and Value

We use (2) when getting css values; Set css to use (1), (3), and (4) as needed ).


We will name chpater03-1.html and chapter03.cssas chapter04-1.htmland chaptper04.css for a demonstration.

A. Read the "font-size" value of ". switcher ".

B. convert to a number

C. Set the font size of the new article.

Js Code

// Get css value    var num = parseFloat($('.switcher').css('font-size'));// Set css valuenum *= 1.4;$('body').css('font-size', num);

Effect

Style Switcher Default Narrow Column Large PrintA Christmas CarolIn Prose, Being a Ghost Story of Christmasby Charles DickensPreface

I HAVE endeavored in this Ghostly little book, to raise the Ghost of an Idea, which shall not put my readers out of humor with themselves, with each other, with the season, or with me. may it haunt their houses pleasantly, and no one wish to lay it.

Their faithful Friend and Servant,

C. D.

December: 1843.

Stave I: Marley's Ghost

MARLEY was dead: to begin. there is no doubt whatever about that. the register of his burial was signed by the clergyman, the clerk, the undertaker, and the chief mourner. scrooge signed it: and Scrooge's name was good upon 'change, for anything he chose to put his hand. old Marley was dead as a door-nail.

Mind! I don't mean to say that I know, of my own knowledge, what there is particle ly dead about a door-nail. I might have been inclined, myself, to regard a coffin-nail as the deadest piece of ironmongery in the trade. but the wisdom of our ancestors is in the simile; and my unhallowed hands shall not disturb it, or the Country's done. you will therefore permit me to repeat, emphatically, that Marley was as dead as a door-nail.

Scrooge knew he was dead? Of course he did. How can it be otherwise? Scrooge and he were partners for I don't know how many years. scrooge was his sole executor, his sole administrator, his sole assign, his sole residuary legatee, his sole friend, and sole mourner. and even Scrooge was not so dreadfully cut up by the sad event, but that he was an excellent man of business on the very day of the funeral, and solemnised it with an undoubted bargain.

The mention of Marley's funeral brings me back to the point I started from. there is no doubt that Marley was dead. this must be distinctly understood, or nothing wonderful can come of the story I am going to relate. if we were not perfectly convinced that Hamlet's Father died before the play began, there wocould be nothing more remarkable in his taking a stroll at night, in an easterly wind, upon his own ramparts, than there wocould be in any other middle-aged gentleman rashly turning out after dark in a breezy spot-say Saint Paul's Church chyard for instance-literally to astonish his son's weak mind.

Scrooge never painted out Old Marley's name. there it stood, years afterwards, abve the warehouse door: Scrooge and Marley. the firm was known as Scrooge and Marley. sometimes people new to the business called Scrooge, and sometimes Marley, but he answered to both names. it was all the same to him.

Oh! But he was a tight-fisted hand at the grind-stone, Scrooge! A squeezing, wrenching, grasping, scraping, clutching, covetous, old sinner! Hard and sharp as flint, from which no steel had ever struck out generous fire; secret, and self-contained, and solitary as an oyster. the cold within him froze his old features, nipped his pointed nose, shrivelled his cheek, stiffened his gait; made his eyes red, his thin lips blue; and spoke out shrewdly in his grating voice. A frosty rime was on his head, and on his eyebrows, and his wiry chin. he carried his own low temperature always about with him; he iced his office in the dog-days; and didn't thaw it one degree at Christmas.

External heat and cold had little influence on Scrooge. no warmth cocould warm, no wintry weather chill him. no wind that blew was bitterer than he, no falling snow was more intent upon its purpose, no pelting rain less open to entreaty. foul weather didn't know where to have him. the heaviest rain, and snow, and hail, and sleet, cocould boast of the advantage over him in only one respect. they often "came down" handsomely, and Scrooge never did.

Nobody ever stopped him in the street to say, with gladsome looks, "My dear Scrooge, how are you? When will you come to see me? "No beggars implored him to bestow a trifle, no children asked him what it was o' clock, no man or woman ever once in all his life inquired the way to such and such a place, of Scrooge. even the blind men's dogs appeared to know him; and when they saw him coming on, wocould tug their owners into doorways and up courts; and then wocould wag their tails as though they said, "No eye at all is better An edevil eye, dark master! "

But what did Scrooge care! It was the very thing he liked. To edge his way along the crowded paths of life, warning all human sympathy to keep its distance, was what the knowing ones call "nuts" to Scrooge.


Appendix:

Chapter04-1.js

$(document).ready(function() {  $('#switcher-large').click(function(e) {// Get css value    var num = parseFloat($('.switcher').css('font-size'));// Set css valuenum *= 1.4;$('body').css('font-size', num);});});


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.