以下是我具有的jQuery代码的一部分,该代码显示文件输入和“清除文件”按钮。
var $imagefile = $('<input />').attr({
type: 'file',
name: 'imageFile',
class: 'imageFile'
});
$image.append($imagefile);
var $imageclear = $('<input />').attr({
type: 'button',
name: 'imageClear',
class: 'imageClear',
value: 'Clear File'
});
$image.append($imageclear);
现在,我拥有“清除文件”按钮的原因是,如果单击该按钮,它将清除文件输入中的所有内容。我如何编码它,以便当我单击“清除文件”按钮时,它实际上清除了文件输入?