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
PHPzforward
2016-05-16 19:21:062511browse

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;");
	}

For more related tutorials, please visit JavaScript video tutorial

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete