Home > Web Front-end > JS Tutorial > How to show or hide a button in js

How to show or hide a button in js

PHPz
Release: 2018-10-10 17:07:35
forward
2490 people have browsed it

There are many ways to show and hide an element. You can find a way on Baidu. Here I will record how I show and hide it for future review.

The requirement is: when the state is 1 and 2, the button (id is plshbtn) is hidden; when the state is 0, the button will be displayed.

js method is as follows:

if($("#state").val()==0){
		$("#plshbtn").attr("style","display:block;");
	}
	if($("#state").val()==1||$("#state").val()==2){
		$("#plshbtn").attr("style","display:none;");
	}
Copy after login

For more related tutorials, please visit JavaScript video tutorial

Related labels:
source:csdn.net
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