App下載
首頁(yè)javascriptstyleJavascript Style - 如何樣式禁用元素與Javascript

Javascript Style - 如何樣式禁用元素與Javascript

我們想知道如何樣式禁用元素與Javascript。

<!DOCTYPE html>
<html>
<head>
<style>
input[disabled] {
  background: yellow;
}
</style>
</head>
<body>
  <input id="foo" type="text">
  <script>
        document.getElementById('foo').disabled = true;
    </script>
</body>
</html>