<input type="file" name="fileupload" onclick="display(img1)">
<img id="img1">function display(img)
{
img.src=当前file控件的值
这里的this 表示什么?
我试过不能用this.value 来表示fileupload.value
}
<img id="img1">function display(img)
{
img.src=当前file控件的值
这里的this 表示什么?
我试过不能用this.value 来表示fileupload.value
}
解决方案 »
- C# Flash 全屏问题
- 为甚麽extjs 的PagingToolbar 显示的总页数 一直是1
- jquery 1.4 以后如何获取 readyList (或者说如何获取闭包中的变量)
- jquery.datatable服务器端分页问题
- 端口问题
- <td>中加链接,如何像<a>一样用target来指定传向的帧?
- 谁知道亿唐网站的下拉菜单是如何做的?
- 类似下拉菜单,不过点击后是横向展开。请问在哪里又啊。
- 关于excel上传文件显示到前端的实现
- 提交表单,request.getParameter("title") 如果参数值title是中文,得出结果却是空。。。。在线等待~!
- javascript在用clipboardData.getData时候的参数,除了Text和URL还有其他没有?我想获得从IE中拷贝出来的文本数据原来所在的URL,就像One
- 一个小错误,请高手帮帮忙
<img id="img1">function display(img)
{
alert(img.value);
}
我的意思是怎么在调用方法的时候把当前对象作为参数
传给该方法
例如
<input type="button" name="button" onclick=a(表示button对象)>
这里的意思是用一个可以表示当前对象的东西传给a方法
function a(currentObject)
{}
显示这个按钮的value 值
应该怎么写?
<input type="button" name="button" value="button">
alert(button.value);
当然我的意思不这样
但跟这个差不多
alert(button.value);
当然我的意思不这样
但跟这个差不多
*//fd
不显示value 显示什么?你能说清楚点么?
还是我表达的有点问题<input type="button" name="button" onclick="a()">
<input type="button" name="button1" onclick="a()">
function a()
{
显示当前按扭对象的value值
}
<input type="button" name="button1" onclick="a(this)">
不就可以了么?
把自己传过去。
直接
alert(arguments[0].value)就可以了。
这个?
我一直以为那个this 表示的不是当前对象
谢谢了
注意这个a不带参数
怎么引用当前按扭对象
//创建类
create: function () {
return function () {
this.initialize.apply(this, arguments);
};
}
};var $A = function (a) {
//转换数组
return a ? Array.apply(null, a) : new Array;
};var $ = function (id) {
//获取对象
return document.getElementById(id);
};Object.extend = function (a, b) {
//追加方法
for (var i in b) a[i] = b[i];
return a;
};Object.extend(Object, { addEvent : function (a, b, c, d) {
//添加函数
if (a.attachEvent) a.attachEvent(b[0], c);
else a.addEventListener(b[1] || b[0].replace(/^on/, ""), c, d || false);
return c;
},
delEvent : function (a, b, c, d) {
if (a.detachEvent) a.detachEvent(b[0], c);
else a.removeEventListener(b[1] || b[0].replace(/^on/, ""), c, d || false);
return c;
},
reEvent : function () {
//获取Event
return window.event ? window.event : (function (o) {
do {
o = o.caller;
} while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
return o.arguments[0];
})(this.reEvent);
}
});Function.prototype.bind = function () {
//绑定事件
var wc = this, a = $A(arguments), o = a.shift();
return function () {
wc.apply(o, a.concat($A(arguments)));
};
};常用函数的说。。^o^方法。。function a() {
var e = Object.reEvent(), o = e.srcElement || e.target;
alert(o.value);
}