<input type="file" name="fileupload"  onclick="display(img1)">
<img id="img1">function display(img)
{
img.src=当前file控件的值
这里的this 表示什么?
我试过不能用this.value 来表示fileupload.value
}

解决方案 »

  1.   

    <input type="file" name="fileupload"  onclick="display(this)">
    <img id="img1">function display(img)
    {
    alert(img.value);
    }
      

  2.   

    不是~
    我的意思是怎么在调用方法的时候把当前对象作为参数
    传给该方法
    例如
    <input type="button" name="button" onclick=a(表示button对象)>
    这里的意思是用一个可以表示当前对象的东西传给a方法
    function a(currentObject)
    {}
      

  3.   

    我的意思是当我按下按钮的时候
    显示这个按钮的value 值
    应该怎么写?
    <input type="button" name="button" value="button">
    alert(button.value);
    当然我的意思不这样
    但跟这个差不多
      

  4.   

    /*
    alert(button.value);
    当然我的意思不这样
    但跟这个差不多
    *//fd
    不显示value 显示什么?你能说清楚点么?
      

  5.   

    郁闷
    还是我表达的有点问题<input type="button" name="button" onclick="a()">
    <input type="button" name="button1" onclick="a()"> 
    function a()
    {
    显示当前按扭对象的value值
    }
      

  6.   

    <input type="button" name="button" onclick="a(this)">
    <input type="button" name="button1" onclick="a(this)"> 
    不就可以了么?
    把自己传过去。
    直接
    alert(arguments[0].value)就可以了。
      

  7.   

    还是你要显示。。<input type="button" name="button1" onclick="a(this)"> 
    这个?
      

  8.   

    原来是这样
    我一直以为那个this 表示的不是当前对象
    谢谢了
      

  9.   

    还是不想传东西利用event取?
      

  10.   

    那要是在function a()里面怎么引用
    注意这个a不带参数
    怎么引用当前按扭对象
      

  11.   

    var Class = {
    //创建类
    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);
    }