The disabled attribute is a Boolean attribute, which stipulates that the input element should be disabled. Disabled input elements are unavailable and cannot be clicked. In the following article, we will take a look at the specific usage of the disabled attribute.
We can set the disabled attribute to prevent users from using the element until other conditions are met (such as selecting a checkbox, etc.). JavaScript can then remove the disabled value and make the element available.
Let’s look at a specific example
The code is as follows
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <form action="/action_page.php"> First name: <input type="text" name="fname"><br> Last name: <input type="text" name="lname" disabled><br> <input type="submit" value="Submit"> </form> </body> </html>
The effect is as follows: If the element has a disabled attribute, it will turn gray and cannot be used.
This article ends here. For more exciting content, you can pay attention to other related column tutorials on the PHP Chinese website! ! !
The above is the detailed content of How to use disabled attribute. For more information, please follow other related articles on the PHP Chinese website!