首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

JQUERY事件解绑有关问题

2013-08-24 
JQUERY事件解绑问题function setAllReadOnly(value) {if (value true) {jQuery(span).live(mousemov

JQUERY事件解绑问题
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包围着。
[解决办法]
事件的未绑定时候。最初是undefined。
给予绑定后。就成了function
你把值改回undefined
例如  ......("mousemove", undefined);

热点排行