How to set the button to disappear after clicking it in html5

WBOY
Release: 2022-01-23 14:10:17
Original
5878 people have browsed it

Method: 1. Bind the click event to the button element and specify the event processing function; 2. In the event processing function, use the style attribute and display attribute to set the button to disappear after clicking the button. The syntax is "button Element object.style.display="none"".

How to set the button to disappear after clicking it in html5

The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.

html5How to set the button to disappear after clicking the button

The Style object represents a separate style statement. A Style object can be accessed from the document or element to which the style is applied.

Syntax for using the Style object attribute:

document.getElementById("id").style.property="值"
Copy after login

The display attribute specifies the type of box that the element should generate.

When the value of the attribute is set to none, this element will not be displayed.

The example is as follows:

<html>
<head>
<script type="text/javascript">
function setStyle()
{
document.getElementById("anniu").style.display="none";
}
</script>
</head>
<body>
<button  onclick="setStyle()" id="anniu">按钮</button>
</body>
</html>
Copy after login

Output result:

How to set the button to disappear after clicking it in html5

Recommended tutorial: "html video tutorial"

The above is the detailed content of How to set the button to disappear after clicking it in html5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!