点击后试图隐藏"下载"按钮

Jou*_*las 0 html javascript php

我有一个简单的表单,只包含一个用于下载文件的按钮.这是代码:

<form method='post' action='download.php?file=file.txt' name='form1'>
<button type='submit'>Telecharger</button>
</form>
Run Code Online (Sandbox Code Playgroud)

Download.php是一个小的php文件,带有用于下载的标题,这里是:

<?php
    $filename=$_GET['file'];
    header('Content-Type: text/plain'); 
    header("Content-disposition: attachment;filename=$filename");
    readfile($filename);
?>
Run Code Online (Sandbox Code Playgroud)

我要做的是在用户点击它之后隐藏按钮或表单.到目前为止,我已尝试使用css和javascript监听器,但到目前为止没有任何工作.

当我点击按钮时,它会下载文件,但不会隐藏按钮.

提交表格后如何隐藏按钮?

Tob*_* F. 5

你可以使用Javascript:

<form method='post' action='download.php?file=file.txt' name='form1'>
  <button onClick='this.style.display = "none";' type='submit'>Telecharger</button>
</form>
Run Code Online (Sandbox Code Playgroud)

这会在点击时隐藏您的按钮.是一个小提琴.