效果图:
?
<div id="uploadDemoView">
<table rules="all" border="1px" id="tabshow" style="text-align: left;">
<tbody>
<tr>
<th>文件名称</th>
<th>文件类型</th>
<th>文件大小</th>
<th>缩略图</th>
<th>文件操作</th>
</tr>
<tr>
<td><input name="fileName" type="hidden" value="1 (2).jpeg"><input name="fileType"
type="hidden" value=".jpeg"><input name="fileSize" type="hidden"
value="44.78"><input name="fileUrl" type="hidden"
value="http://127.0.0.1/profile/upload/2022/03/13/f2b03c9b-8ae4-47d9-9a7c-44632b16760a.jpeg">1
(2).jpeg </td>
<td> .jpeg </td>
<td> 44.78 KB</td>
<td><img alt="1 (2).jpeg"
src="http://127.0.0.1/profile/upload/2022/03/13/f2b03c9b-8ae4-47d9-9a7c-44632b16760a.jpeg"
style="width: 60px;height: 60px"></td>
<td><a target="_blank"
href="http://127.0.0.1/profile/upload/2022/03/13/f2b03c9b-8ae4-47d9-9a7c-44632b16760a.jpeg">查看</a>
<a onclick="copyText(this)">点击复制</a> </td>
</tr>
<tr>
<td><input name="fileName" type="hidden" value="1 (1).jpeg"><input name="fileType"
type="hidden" value=".jpeg"><input name="fileSize" type="hidden"
value="128.80"><input name="fileUrl" type="hidden"
value="http://127.0.0.1/profile/upload/2022/03/13/1f92cfbf-60e4-475f-a760-72a636d53ea6.jpeg">1
(1).jpeg </td>
<td> .jpeg </td>
<td> 128.80 KB</td>
<td><img alt="1 (1).jpeg"
src="http://127.0.0.1/profile/upload/2022/03/13/1f92cfbf-60e4-475f-a760-72a636d53ea6.jpeg"
style="width: 60px;height: 60px"></td>
<td><a target="_blank"
href="http://127.0.0.1/profile/upload/2022/03/13/1f92cfbf-60e4-475f-a760-72a636d53ea6.jpeg">查看</a>
<a onclick="copyText(this)">点击复制</a> </td>
</tr>
</tbody>
</table>
</div>
?
function copyText(item) {
var cptext = $(item).parents('tr').find('td:eq(3)>img').attr('src');
copyToClipboard(cptext);
}
/**
* 拷贝到粘贴板
* @param {Object} element
*/
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val(element).select();
document.execCommand("copy");
$temp.remove();
$.modal.msg("拷贝成功! ");
}
|