jQuery1.4学习(1) 2010/01/15

      jQuery 1.4 发布了

     在 jQuery 诞生4周年(1月14日)之际,jQuery的开发团队经过大量的编码、测试后,发布了最新版本的jQuery Javascript库 jQuery1.4。官方提供了两个版本(一个压缩版,一个未压缩的)

  • jQuery Minified (23kb Gzipped)
  • jQuery Regular (154kb)
  •       新版本的性能有很大提升,对代码库进行了内部重写组织,开始建立一些风格规范。老的core.js文件被分为attribute.js, css.js, data.js, manipulation.js, traversing.js和queue.js。CSS和attribute的逻辑分离。并修正了207个老版本的错误。

          更容易使用的设置函数(Easy Setter Functions

          早些时候,我们可以传递一个function给 .attr() 方法,该 function 的返回值可以设置给对应的 attribute ,现在这个机制被延伸到所有的设置函数:.css(), .attr(), .val(), .html(), .text(), .append(), .prepend(), .before(), .after(), .replaceWith(), .wrap(), .wrapInner(), .offset(), .addClass(), .removeClass(), 和.toggleClass()。

          此外,下列这些设置函数,项目的当前值会被传递到 function 的第二个参数:.css(), .attr(), .val(), .html(), .text(), .append(), .prepend(), .offset(), .addClass(), .removeClass(), 和.toggleClass().

    // 查找标记 A 内的所有 '&' 替换为 '<span>&</span>'
    $('a').html(function(i,html){
      return html.replace(/&/gi,'<span class="amp">&</span>');
    });

    // 添加一些内容给 A 的 title
    $('a[target]').attr("title", function(i,title){
      return title + " (Opens in External Window)";
    });

          此外,还很多地方进行了改进和更新,详情可以看这里 http://jquery14.com/day-01/jquery-14

    Leave a Reply