function setAllReadOnly(value) {
if (value == true) {
jQuery("span").live("mousemove", function () { this.setCapture(); }).live("mouseout", function () { this.releaseCapture(); }).live("focus", function () { this.blur(); }).live("before", function () { return false; });
} else if (value == false) {
jQuery("span").unbind("mousemove");
jQuery("span").unbind("mouseout");
jQuery("span").unbind("focus");
jQuery("span").unbind("before");
}
}
代码如上,我想做的是 根据条件对于页面中的<span>进行事件的绑定与解绑,为了让<span>中的控件达到只读效果。现在添加事件后能达到只读效果,但我想解除绑定事件的时候,我发现unbind()执行了,但貌似没效果。新手第一次接触jquery,还有大家怎么解决控件只读的,我搜到的方法就是用span包围着。
if (value == true) {
jQuery("span").live("mousemove", function () { this.setCapture(); }).live("mouseout", function () { this.releaseCapture(); }).live("focus", function () { this.blur(); }).live("before", function () { return false; });
} else if (value == false) {
jQuery("span").unbind("mousemove");
jQuery("span").unbind("mouseout");
jQuery("span").unbind("focus");
jQuery("span").unbind("before");
}
}
代码如上,我想做的是 根据条件对于页面中的<span>进行事件的绑定与解绑,为了让<span>中的控件达到只读效果。现在添加事件后能达到只读效果,但我想解除绑定事件的时候,我发现unbind()执行了,但貌似没效果。新手第一次接触jquery,还有大家怎么解决控件只读的,我搜到的方法就是用span包围着。
给予绑定后。就成了function
你把值改回undefined
例如 ......("mousemove", undefined);
不知道是不是和这个未来有关系.
我用bind 是可以做做移除的 你试试用bind来添加事件
不知道是不是和这个未来有关系.
我用bind 是可以做做移除的 你试试用bind来添加事件真的管用。虽然不知道为什么,先这样吧,感谢,结贴。