Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在server.javascript jquery中删除文件时如何删除网站中的str(name+;size+;cancel)_Javascript_Jquery_Css_Ajax - Fatal编程技术网

在server.javascript jquery中删除文件时如何删除网站中的str(name+;size+;cancel)

在server.javascript jquery中删除文件时如何删除网站中的str(name+;size+;cancel),javascript,jquery,css,ajax,Javascript,Jquery,Css,Ajax,我使用ajaxsubmit将文件上传到linux服务器。成功上传文件后,文件名+文件大小+取消按钮将出现在我的网站上。以下是我的html代码: <style type="text/css"> .files{height:10px; font-size:10px;line-height:22px; margin:10px 0} </style> <div class="files"></div> 不幸的是,它失败了。下面是我想实现的示例。在单击“取

我使用ajaxsubmit将文件上传到linux服务器。成功上传文件后,文件名+文件大小+取消按钮将出现在我的网站上。以下是我的html代码:

<style type="text/css">
.files{height:10px; font-size:10px;line-height:22px; margin:10px 0}
</style>
<div class="files"></div>
不幸的是,它失败了。下面是我想实现的示例。在单击“取消”之前,我的文件div内容是:

1.jpg(10.36k) cancel
2.jpg(10.36k) cancel
3.jpg(10.36k) cancel
单击第二个按钮后,我的文件div内容为:

1.jpg(10.36k) cancel
3.jpg(10.36k) cancel

谁能帮我?

问题是
id='dataname

不能使用同一
id
的倍数
改为使用类。 在这里

所以…

而不是

并删除无用的
id='cancelbtn'

然后,单击事件处理程序应为:

$(document).on('click',".delimg",function(){
    $(this).prev('.dataname').remove(); // removes the filename
    $(this).remove(); // Removes the "cancel"
});
这里不需要正则表达式。
您有一些类以要删除的元素为目标


正则表达式用于以字符串中的字符模式为目标。

问题在于
id='dataname

不能使用同一
id
的倍数
改为使用类。 在这里

所以…

而不是

并删除无用的
id='cancelbtn'

然后,单击事件处理程序应为:

$(document).on('click',".delimg",function(){
    $(this).prev('.dataname').remove(); // removes the filename
    $(this).remove(); // Removes the "cancel"
});
这里不需要正则表达式。
您有一些类以要删除的元素为目标


正则表达式用于以字符串中的字符模式为目标。

,如何使用类?你能告诉我密码吗?对不起,我不知道如何使用课堂。我用一些具体的东西改进了答案。;),如何使用类?你能告诉我密码吗?对不起,我不知道如何使用课堂。我用一些具体的东西改进了答案
$(document).on('click',".delimg",function(){
    $(this).prev('.dataname').remove(); // removes the filename
    $(this).remove(); // Removes the "cancel"
});