jQuery技术

学习JQuery - 1

字号+ 作者:H5之家 来源:H5之家 2017-06-18 08:00 我要评论( )

学习JQuery - 1。建议的开发环境: 1. web浏览器 (1) Google Chrome(V31.0.1650.63 m +) (2) Firefox(V26.0+) 调试插件:Firebug(V1.12.5+) 2. HTML编辑器 Adobe

 

 

建议的开发环境:

1. web浏览器

(1) Google Chrome(V31.0.1650.63 m +)

(2) Firefox(V26.0+)

调试插件:Firebug(V1.12.5+)

2. HTML编辑器

Adobe Dreamweaver CS6(V12.0+)

3. JQuery(V1.10.2+)

 

第一章:

请把下面的HTML文件中的“YKCOWREBBAJ”和“JABBERWOCKY”部分加高亮。

chapter1-1.html

 

<script type=text/javascript src=jquery-1.10.2.js></script><script type=text/javascript src=chapter01.js></script>

Through the Looking-Glass

by Lewis Carroll

1. Looking-Glass House

There was a book lying near Alice on the table, and while she sat watching the White King (for she was still a little anxious about him, and had the ink all ready to throw over him, in case he fainted again), she turned over the leaves, to find some part that she could read, -for it's all in some language I don't know, she said to herself.

It was like this.

YKCOWREBBAJ

sevot yhtils eht dna ,gillirb sawT'

;ebaw eht ni elbmig dna eryg diD

,sevogorob eht erew ysmim llA

.ebargtuo shtar emom eht dnA

She puzzled over this for some time, but at last a bright thought struck her. Why, it's a Looking-glass book, of course! And if I hold it up to a glass, the words will all go the right way again.

This was the poem that Alice read.

JABBERWOCKY

'Twas brillig, and the slithy toves

Did gyre and gimble in the wabe;

All mimsy were the borogoves,

And the mome raths outgrabe.

此HTML主要的由两个class为poem的div组成。

 

 

chapter01.css

 

@charset utf-8; /* CSS Document */ html, body { margin: 0; padding: 0; } body { font: 62.5% Verdana, Geneva, sans-serif; background: #fff; color: #000; } #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; } .poem { margin: 0 2em; } .highlight { background-color: #ccc; border: 1px solid #888; font-style: italic; margin: 0.5em 0; padding: 0.5em; } 本例主要用到.poem和.highlight。

下面我们编写完成工作的JS。

 

把css中定义的“.highlight”增加到poem-stanza的div中
chapter01.js

 

$(document).ready(function() { $('div.poem-stanza').addClass('highlight'); });

 

 

其中

 

$(document).ready(function() { // TODO }); 是JQuery的标准写法。只要我们使用JQuery都要在TODO中编写代码。

 

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • jquery(js)判断页面滚动条(scroll)是向上滚还是向下滚方向判断

    jquery(js)判断页面滚动条(scroll)是向上滚还是向下滚方向判断

    2017-06-18 10:00

  • 学习记录jQuery的animate函数,jqueryanimate函数

    学习记录jQuery的animate函数,jqueryanimate函数

    2017-06-17 18:00

  • 滚屏加载--无刷新动态加载数据技术的应用

    滚屏加载--无刷新动态加载数据技术的应用

    2017-06-17 10:00

  • jQuery简单绑定单个事件的方法示例

    jQuery简单绑定单个事件的方法示例

    2017-06-15 10:00

网友点评