第四章 Styling and Animating

1. 使用内联属性修改CSS

我们知道HTML在onload时会读取css的各项值。

那么,我们能不能在之后的操作中改变css值呢?

答案是肯定的!要不然,我们前几章就不会出现那么多不同的效果了。

那么jQuery通过那个方法控制的CSS值呢?

css()

jQuery无论获取或者设置css值都是通过这个方法。

在DW中键入“css”后的提示如下:

(1) 使用映射,即K-V

(2) 属性名

(3) 属性名和索引值

(4) 属性名和值

我们获取css值时使用(2); 设置css根据情况使用(1)、(3)、(4)。

我们把chpater03-1.html, chapter03.css更名为chapter04-1.html和chaptper04.css来做一演示。

a. 读取“.switcher”的“font-size”值

b. 转换为数字

c. 设置新的文章字体大小

js代码

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

实现效果

Style Switcher

Default  Narrow Column   Large Print

A Christmas Carol

In Prose, Being a Ghost Story of Christmas

by Charles Dickens

Preface

I HAVE endeavoured in this Ghostly little book, to raise the Ghost of an Idea, which shall not put my readers out of humour 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 with. 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 to. Old Marley was as dead as a door-nail.

Mind! I don't mean to say that I know, of my own knowledge, what there is particularly 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 for. 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 could 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 would be nothing more remarkable in his taking a stroll at night, in an easterly wind, upon his own ramparts, than there would be in any other middle-aged gentleman rashly turning out after dark in a breezy spot—say Saint Paul's Churchyard for instance— literally to astonish his son's weak mind.

Scrooge never painted out Old Marley's name. There it stood, years afterwards, above the warehouse door: Scrooge and Marley. The firm was known as Scrooge and Marley. Sometimes people new to the business called Scrooge 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 could 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, could 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, would tug their owners into doorways and up courts; and then would wag their tails as though they said, "No eye at all is better than an evil 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.

附:

chapter04-1.js

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

转载于:https://www.cnblogs.com/fuhaots2009/p/3503449.html

学习JQuery - 10相关推荐

  1. 学习jQuery之旅--使用炫酷的jQuery插件

    前两篇文章中,介绍了jQuery中强大的Selectors (选择器)以及开发中比较常用的方法的使用.今天和大家一起体验一下jQuery另一个吸引人的地方--强大炫酷实用的jQuery插件. 做网站的 ...

  2. 从零开始学习jQuery (九) jQuery工具函数

    本系列文章导航 从零开始学习jQuery (一) 开天辟地入门篇 从零开始学习jQuery (二) 万能的选择器 从零开始学习jQuery (三) 管理jQuery包装集 从零开始学习jQuery ( ...

  3. 从零开始学习jQuery (七) jQuery动画-让页面动起来!

    本系列文章导航 从零开始学习jQuery (一) 开天辟地入门篇 从零开始学习jQuery (二) 万能的选择器 从零开始学习jQuery (三) 管理jQuery包装集 从零开始学习jQuery ( ...

  4. 深入学习jquery源码之高德地图组件的使用

    深入学习jquery源码之高德地图组件的使用 高德地图组件是一类高度模块化的LBS服务组件,开发者通过调用相应标签便可轻松实现诸如在地图上标注点.查找附近poi.公交/驾车线路规划等功能.该类组件仅针 ...

  5. 2022 年最值得学习的 10 种编程语言 [更新]

    大家好,我们距离 2022 年只有一周的时间.这是我们大多数人开始制定目标的时候,比如身体目标.教育目标和财务目标.作为一名程序员,我们的目标之一是学习新技术和编程语言,但是你应该学习哪些语言呢?因为 ...

  6. Java程序员应该学习的10件清单

    作为程序员,我们最大的挑战是让自己保持最新状态.技术变化非常快,每隔几年你就会看到一个新版本的编程语言和框架出现. 扫码关注<Java学研大本营>,加入读者群,分享更多精彩 当2021 年 ...

  7. JavaWeb黑马旅游网-学习笔记10【项目代码】

    Java后端 学习路线 笔记汇总表[黑马程序员] JavaWeb黑马旅游网-学习笔记01[准备工作] JavaWeb黑马旅游网-学习笔记02[注册功能] JavaWeb黑马旅游网-学习笔记03[登陆和 ...

  8. 12个很棒的学习 jQuery 的网站推荐

    原文地址为: 12个很棒的学习 jQuery 的网站推荐 jQuery是目前最流行的 JavaScript 库.对于初学者来说,有的时候很难找到一个好的学习jQuery的网站,今天本文收集了12个很棒 ...

  9. Python|http|Chrome Developer Tools|Postman|HTTPie|builtwith库|python-whois库|爬虫及解析|语言基础50课:学习(10)

    文章目录 系列目录 原项目地址 第31课:网络数据采集概述 爬虫的应用领域 爬虫合法性探讨 Robots协议 超文本传输协议(HTTP) 相关工具(Chrome Developer Tools.Pos ...

最新文章

  1. 超详细派克斯使用安装教程
  2. 依赖注入容器Autofac的详解[转]
  3. App相互唤醒的几种方式
  4. CodeForces 351A Jeff and Rounding
  5. 关于XML序列化与CultureInfo
  6. vue ---- 将项目打包发布
  7. 为什么B+树适合做索引
  8. python用缩进来写模块_进击python第一篇:相遇
  9. Sql server 2008 R2 导出/导入数据报错之无法打开全局共享内存以与性能 DLL 通信
  10. CMMI3级认证过程记录
  11. GAN(生成对抗神经网络)生成MNIST 基于pytorch实现
  12. 【原创】St2-057检测工具(Apache Struts2远程代码执行高危漏洞)
  13. 前端练习:day02
  14. 台式机装苹果系统_苹果电脑macbook装windows系统U盘启动的详细方法
  15. SAP MM 采购订单中“Delivery Completed“ Indicator
  16. 计算机桌面无法中英文切换,输入法无法切换到中文怎么办_输入法失效只能打英文的解决方法...
  17. bitcoin全节点搭建
  18. Nodejs ORM Prisma 介绍
  19. vue3+TypeScript实现导出Excel功能
  20. keep跑步数据修改器_一只手环就能指导运动?Keep 想做你手腕上的魔鬼教练

热门文章

  1. 【报错解决】为Blender构建Python模块
  2. echarts设置label添加下划线
  3. 转:中国移动宽带光猫F663路由模式改桥接模式
  4. -XX:+PrintGCTimeStamps 打印CG发生的时间戳
  5. electron 主进程与渲染进程通讯
  6. redis主从+哨兵
  7. 十问旷视印奇、唐文斌:AI企业都在经历「死亡之谷」
  8. 《如师通语言学习软件(罗塞塔石碑)》(Rosetta Stone) v3.4.5 英语/日语/法语/德语/韩语/俄语/西班牙语/意大利语/阿拉伯语/葡萄牙语/汉语 [云端免安装版]
  9. 父类对象指向子类引用
  10. Linux 系统安全应用