1、JS中的事件监听器是否只能加在dom对象上,而不能加在普通对象上,例如:var a=“”;2、JS中有没有数据绑定,例如将某个变量绑定在某个控件的value上等;3、JS一般有哪些DataGrid,能根据数据自动生成行,数量过大时自动出现滚动条;4、$(document).mouseup(function(e){});与
$(document).bind("click", funciton(e){});5、$(document).bind(.. 是否就是addEventListener/attachEvent的封装?
$(document).bind("click", funciton(e){});5、$(document).bind(.. 是否就是addEventListener/attachEvent的封装?
1,事件是界面元素(控件)独有的东东,变量怎么会有事件?
2,这个功能直接用js给控件的value赋值就可以了,谈不上绑定
3,js里面只能实例化html元素,没有datagrid之类东东,很多js库有这个,但那是别人写的控件(也是基于HTml元素的),也都是基于html元素的(所有内容呈现在页面时都肯定是html元素),像grid那样的控件,一般是table元素处理出来的
2、绑定就是赋值
3、找js ui 库,或者自己实现
4、应该是juery的,看juery 源码就知道了
5、是的,看juery 源码
+1补充 2、可以通过模板和占位符进行替换填充绑定,特别是绑定list的时候
嗯,放到别的上面也没用对吧2、JS中有没有数据绑定,例如将某个变量绑定在某个控件的value上等;
就是操作dom3、JS一般有哪些DataGrid,能根据数据自动生成行,数量过大时自动出现滚动条;
自己封装
4、$(document).mouseup(function(e){});与
$(document).bind("click", funciton(e){});
一样的 mouseup是bind的简化5、$(document).bind(.. 是否就是addEventListener/attachEvent的封装?
不是 addEventListener/attachEvent 有bug 处理方法 百度下吧
这点不对 应该是一样的 mouseup是bind的简化而已实现原理都是一样
this 其实就是执相“目标”对象function a(){this.a =10 //
}
a() //执行的时候this指向windownew a() //执行的时候指向 当前对象
$(document).click(function(event){document.write("_click");});
$(document).click(function(event){document.write("_click2");});
确实可以分别执行的,与bind一样;而
document.onclick = function(event){document.write("_click");};
document.onclick = function(event){document.write("_click");};则只能执行一个;我上面说的this只是一个例子,一般想查一个对象的类型和含有什么值时,是不是只能通过firebug去debug才能看到
attachEvent就可以执行多个
$(function(){
var self = this;
$(document).bind("mousedown", function(event){
document.write("_mouseDown");
this._mouseUpDelegate = function(event){
//self._mouseUp(event);
//this._mouseUp(event);
//document._mouseUp(event);
_mouseUp(event);
};
$(document)
.bind("mouseup", this._mouseUpDelegate);
});
var _mouseUp = function(event){
alert("_mouseUp");
};
});
typeof 检查类型
var self = this; //这里this指向的是window
$(document).bind("mousedown",
function(event) {
document.write("_mouseDown");
//this指向document
this._mouseUpDelegate = function(event) {
//self._mouseUp(event); 指向widnow
//this._mouseUp(event); 指向document
//document._mouseUp(event);
_mouseUp(event);
}; $(document).bind("mouseup", this._mouseUpDelegate);
}); var _mouseUp = function(event) {
alert("_mouseUp");
};
});
那_mouseUp 是哪个对象的方法呢?因为我用注释里的3种都不能触发_mouseUp 方法,只有直接用_mouseUp(event);才能触发
$(function() {
var self = this; //这里self指向的是document
$(document).bind("mousedown",function(event) {
this._mouseUpDelegate = function(event) {//这个this指向document
//self._mouseUp(event); self指向document 执行 document的_mouseUp方法
//this._mouseUp(event);this 指向document 执行 document的_mouseUp方法
//document._mouseUp(event); 执行 document的_mouseUp方法
_mouseUp(event);
};
$(document).bind("mouseup", this._mouseUpDelegate);
});
function _mouseUp(event) {//这样才能访问到 但是这个函数是window下的 不是document的 所以 上面三种都访问不到的
alert("_mouseUp");
};
});
1>事件监听器一样可以加在变量上....一般这样的事件都是自定义事件,因为常用事件没法绑定在不可见对象上.
2>js是基于事件的和as一样,通过封装一样可以实现数据绑定....as中的绑定.
3>这个也要自己封装
其它两个是jquery里的.....慢慢查吧