JQuery笔记
天才第一步: :oops: :oops:
- 下载jQuery.js并保存在网页可以存取的位置。下载链接:http://docs.jquery.com/Downloading_jQuery
- 在HTML的head里引用jQuery.js
- 运用jQuery的方法
{:a => 1, :b => 3}
merged_obj = obj.merge(:c => 4, :a => 5) #=> {:a=>5, :b=>3, :c=>4}
js merge Object:
var settings = { validate: false, limit: 5, name: "foo" };
var options = { validate: true, name: "bar" };
jQuery.extend(settings, options);
stopPropagation() 方法
不再派发事件。 终止事件在传播过程的捕获、目标处理或起泡阶段进一步传播。调用该方法后,该节点上处理该事件的处理程序将被调用,事件不再被分派到其他节点。
重于暂时摆脱js了。。。
貌似我的冒泡没用对。。。。惭愧 :(
今天重构代码时候试了下事件上移。。。但是没弄好(^o^)/~.. 又发现了$("#xx").live("click", function(){alert("oo");}) jquery 1.3新加的好像是。据说性能有点损失。
string to json and json stringfy http://www.dreamdu.com/blog/2008/10/19/json_in_javascript/
Rails authenticity token with jQueryhttp://henrik.nyh.se/2008/05/rails-authenticity-token-with-jquery
对象的constructor属性 每一个javascript对象都有一个constructor属性.这个属性对应了对象初始化时的构造函数(函数也是对象).
rails 里使用jQuery: http://jimneath.org/2008/06/18/using-jquery-with-ruby-on-rails
If no target is specified, the JQuery namespace itself is extended. This can be useful for plugin authors wishing to add new methods to JQuery.
If a boolean true is specified as the first argument, JQuery performs a deep copy, recursively copying any objects it finds. Otherwise, the copy will share structure with the original object(s).
Undefined properties are not copied. However, properties inherited from the object's prototype will be copied over.
Returns
Object
Parameters
deep (Boolean): If set, the merge becomes recursive (i.e. deep copy). target (Object): The object to extend. object1 (Object): The object that will be merged into the first. objectN (Object): More objects to merge into the first. Example
Merge settings and options, modifying settings.
jQuery Code
Example
Merge defaults and options, without modifying the defaults.
jQuery Code
change是可以监听到的,因为后改变是是option,而change是绑定在select上的,见
还有就是关于新建元素的事件绑定问题,最easy的做法是利用事件冒泡,把事件绑定在将要填加元素的父元素上,再要根据这个事件的target来判断触发事件的元素是不是自己填加的那个。
ok了......哇咔咔。
还用each啊,我第一次用了个for in结果不行...后来换成这么笨的方法了。现在又遇到了个问题,我这样append的option,我如何去监视他的evet呢?貌似没有触发onchange,我想在country select后加载全部city,然后获取被选中的city的值。
这个很眼熟嘛。。