Posted by linyupark :: 2007,September 16th,10:34 am
相对于jQuery1.1.4来说jQuery1.2新加了不少新特性。
下载地址:
jQuery 1.2: (升级办法)
jQuery 缩小版本 (14kb 使用了 Gzipping)
jQuery 打包版 (26kb)
jQuery 常规版 (77kb)
直接更换后发现$().eq(index) 的写法已经不再适合使用,要替换成$(… element:eq(index))。
jQuery1.2在CSS部分新加入的height()和width()属性可以很好解决一些图象未在HTML中定义宽高值的获取问题(直接使用.css(”height”)在IE中无法获取)
Posted by linyupark :: 2007,September 8th,15:33 pm
Create DOM elements on-the-fly from the provided String of raw HTML.
You can pass in plain HTML Strings written by hand, create them using some template engine or plugin, or load them via AJAX. There are limitations when creating input elements, see the second example.
通过指定未加工过的HTML代码串来建立一个并未工作的DOM元素。
你可以手写一段HTML代码,使用一些模板或是插件来建立它们,或者由AJAX来加载它们。在建立input元素的时候有一些局限性。
个人实践
依然是上次的实验代码:
<h1 id=”t1″><span>第一部分</span> 马克思注意<span>哲学<b>原理</b></span></h1>
我们先用$(html)来生成一段临时HTML代码:
var small_txt = $(”<small>小写的字</small>”) ;
然后我们把这段HTML替换h1元素里的内容:
$(”h1#t1″).html(small_txt);
上面的两段也可以变成一行:
$(”h1#t1″).html($(”<small>小写的字</small>”));
这里我们提前用到了一个jQuery属性html(val),作用就是向指定的对象里添加HTML代码,有点类似innerHTML。
经过上面代码的一折腾,原来在h1中显示的“第一部分 马克思注意哲学原理”就变为“小写的字”了。
Posted by linyupark :: 2007,September 8th,9:43 am
jQuery( expression, context ) 返回: jQuery
This function accepts a string containing a CSS or basic XPath selector which is then used to match a set of elements.
此函数可接受包含CSS或是基本XPath选择器的字符串,以此来匹配一组元素。
The core functionality of jQuery centers around this function. Everything in jQuery is based upon this, or uses this in some way. The most basic use of this […]
Posted by linyupark :: 2007,September 8th,8:28 am
jQuery is a new type of JavaScript library.
jQuery 是一种新型的JavaScript库。
jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.
jQuery是一种快速,简练的JavaScript库,它可以让你在HTML文档的处理上做到游刃有余,事件处理,动态执行,还可以为你的WEB页面上增加Ajax互动。jQuery的出现会改变你编写JavaScript的方法(让它更轻松简单)。
以上是官方给jQuery给出的定位,因为前段时间自己一直是在使用prototype的,但发现prototype过于臃肿,而且jQuery执行效率非常高,最后还是选择了jQuery来作为现在以及将来主要的JS库。
结果也非常满意,手上的项目对JS的使用非常频繁,还有很多AJAX的应用,jQuery都一一轻松解决,代码看上去也非常的干净。所以想要更深入学习。
网上所给出的API中文手册很多在新版本的jQuery里都失去的效用,加上自己还需要再深入了解jQuery,所以打算慢慢翻译其API并结合自己的实践。自己学习的同时也可以帮助对jQuery感兴趣的朋友。
因为jQuery随时还会更新,本人主要参考其官方的API进行展开。