jQuery

由href return false 来看阻止默认事件

Posted by bower on February 09, 2012
javascript / 1 Comment

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

很多时候我们都想阻止一个a  link的href跳转,

<a onclick=”return false;” href=”www.360.cn”>click</a>

Continue reading…

Tags: ,

jquery ajax callback context changed

Posted by bower on September 22, 2010
javascript / No Comments

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

the context in ajax call back is not the same one I pass in to it, at lease in IE its not, I think it just been cloned
since I got the problem in IE, and I debug it for 2 hours and find the problem.

Continue reading…

Tags:

jquery bind 改变context this指向

Posted by bower on September 18, 2010
javascript, / No Comments

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

myObject = function(){
this.clicked = false;

}
myObject.prototype.click = function(e){
this.clicked = true;
var dom = e.target
}
var myOinstance = new myObject()
$('#myid').bind('click',myOinstance.click);

以上代码OO思想意图不会被实现 ,因为myOinstance.click中的this指向$(‘#myid’)的dom元素,而不是myOinstance
很可惜目前jquery不提供更改this指向或改变context的bind方法,我们要自己做一个扩展。

Continue reading…

Tags:

jQuery: Understanding the “chain”

Posted by bower on March 16, 2010
javascript / No Comments

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

jQuery: Understanding the “chain”
Categories: Source Code, JavaScript, jQuery

Yesterday I was writing some jQuery code and I thought I came across a bug—until I realized it was a bug in my way of thinking and not with jQuery.

Continue reading…

Tags: ,