2010-06-09 187 views
2

这是我的Html代码,我试图将我的id(test1)传递给fileUp函数。它只在我输入'test1'时起作用,当我试图传递一个变量时停止工作。请让我知道是否有办法解决这个问题。如何将值传递给ajaxUpload函数?

<a id='test1' href="#" onclick="fileUp(1, 'test1')">Upload Your file</a>

function fileUp(id,nameTest){ 
    var test=nameTest; 

    new AjaxUpload(nameTest , { 
     action: 'upload-test.php', 
     onComplete: function(file, response){       
      alert(response); 
     } 
    }); 
}; 

回答

2

你是什么意思 “它不工作” 吗?

<a id='test1' href="#" onclick="fileUp(1, this.id)">Upload Your file</a> 

在jQuery中:

$('#test1').bind('click', function (evt) { 
    fileUp(1, $(this).attr('id')); 

    evt.preventDefault(); 
});