`

jquery recipes part one

    博客分类:
  • web
阅读更多
down jquery from : http://jquery.com. this test version is 1.3.2
http://www.w3school.com.cn/tags/tag_span.asp //查看HTML定义
1.2 选择DOM节点
$(document).ready(function() {
    $('p').addClass('highlight');
});
1.3延迟JavaScript的执行
$(document).ready()给文档注册了一个ready()事件。
1.5选择非标准的HTML元素
$('span:contains(Life)').addClass('highlight'); //设置包含Life的文本指定的样式
$('div:odd').addClass('highlight');  //设置div位置在奇数
$('div:even').addClass('boundary'); //设置div位置在偶数为另一种样式
$('p:eq(1)').addClass('Linkstyle'); //设置第二个p的样式,下标从0开始
1.6计数DOM节点和显示其文本
$(document).ready(function()  {
    var $nodes=$('root').children();
    alert('Number of nodes is ' + $nodes.length);
    var txt="";
    $nodes.each( function() {
         txt+=$(this).text();
    });
alert(txt);
});

alert($('span').parent().text());
1.7 获取一个元素的HTML代码
$(document).ready(function() {
alert($('#p1').html()) //输出为代HTML标签的内容
});
1.8改变DOM节点的内容
$('h2').text('Come on baby'); //插入文本
$('h2').html('Come on baby'); //插入HTML,显示为格式化后的HTML
1.9快速创建DOM节点
创建DOM节点的方法有prepend(),prependTo(),和clone()其它创建方法还有append(), appendTO(),  before(), insertBefore(), after(), insertAfter()。
1 prepend()
  $('p').prepend('<h2>Power of selectors</h2>');
2 prependTo()
$('<h2>Power of selectors</h2>').prependTo('p'); //显示效果同上
$('h2').clone().prependTo('p');//将h2的内容复制一份到p
2.0动态修改样式
$('.feature').addClass('boundary');
分享到:
评论

相关推荐

    jQuery Recipes (January 2010)

    ### jQuery Recipes: A Problem-Solution Approach #### 一、书籍简介 《jQuery Recipes》是一本由B.M. Harwani撰写的专为中级用户设计的Web开发书籍,它旨在通过解决实际问题的方式帮助读者深入理解jQuery框架的...

    Apress.jQuery.Recipes.A.Problem.Solution.Approach.Jan.2010

    根据给定的文件信息,我们可以提炼出以下关于《jQuery Recipes: A Problem-Solution Approach》的知识点: ### 书籍概述 《jQuery Recipes: A Problem-Solution Approach》是一本由B.M. Harwani编写的专家级解决...

    jquery-2-recipes:Arun Pande的“ jQuery 2 Recipes”源代码-jquery source code

    Apress源代码 该存储库随附Arun Pande撰写的 (Apress,2014年)。 使用绿色按钮将文件下载为zip格式,或使用Git将存储库克隆到您的计算机上。 发行版 版本v1.0对应于已出版书籍中的代码,没有更正或更新。...

    Ajax and REST Recipes.part2.rar

    Apress 出版的介绍ajax和REST架构的书《Ajax and REST Recipes》pdf(带书签),由于上传文件大小的限制,这是第二个包。

    [jQuery] jQuery 开发技巧 (英文版)

    ☆ 资源说明:☆ ...[Apress] jQuery Recipes (E-Book) ☆ 出版信息:☆ [作者信息] B.M. Harwani [出版机构] Apress [出版日期] 2010年01月12日 [图书页数] 456页 [图书语言] 英语 [图书格式] PDF 格式

    Ajax and REST Recipes.part1.rar

    Apress 出版的介绍ajax和REST架构的书《Ajax and REST Recipes》pdf(带书签),由于上传文件大小的限制,这是第一个包。

    jQuery UI Cookbook (pdf + ePub)

    “jQuery UI Cookbook” provides you with practical recipes featuring in-depth coverage of every widget in the framework, including how to address limitations that impact your everyday development ...

    Entity Framework 6 Recipes

    Entity Framework 6 Recipes Entity Framework 6 Recipes

    Numerical recipes in C++源代码

    Numerical recipes in C++ 第三版源代码; 经典名著,经典代码

    jquery ui及jquery mobile技巧与示例源代码

    原书名:jQuery, jQuery UI, and jQuery Mobile: Recipes and Examples 原出版社: Addison-Wesley Professional 作者: (荷)Adriaan de Jonge (美)Phil Dutson 译者: 包勇明 程学彬 出版社:人民邮电出版社 ...

    Oracle Database 12c Performance Tuning Recipes

    Oracle Database 12c Performance Tuning Recipes is a ready reference for database administrators in need of immediate help with performance issues relating to Oracle Database. The book takes an example...

    Java 9 Recipes, 3rd Edition.pdf

    Java 9 Recipes, 3rd Edition.pdf Java 9 Recipes, 3rd Edition.pdf Java 9 Recipes, 3rd Edition.pdf Java 9 Recipes, 3rd Edition.pdf

    数值分析(计算方法)超经典Numerical Recipes 源码.zip

    《数值分析(计算方法)超经典Numerical Recipes 源码.zip》是一个包含多语言版本的数值计算方法源代码库,适用于C#开发者以及其他编程语言的学习者。Numerical Recipes是一本广泛使用的经典教材,它提供了丰富的算法...

Global site tag (gtag.js) - Google Analytics