Baseline Widely available
HTMLStyleElement.disabled
ããããã£ã¯ããã®ã¹ã¿ã¤ã«ã·ã¼ããç¡å¹ (true
) ãããã§ãªãã (false
) ãåå¾ã¾ãã¯è¨å®ããããã«ä½¿ç¨ãããã¨ãã§ãã¾ãã
ãªãã対å¿ãã disabled
屿§ã¯ HTML ã® <style>
è¦ç´ ã«ã¯ããã¾ããã
ãã®ã¹ã¿ã¤ã«ã·ã¼ããç¡å¹ãã¾ãã¯é¢é£ä»ããããã¹ã¿ã¤ã«ã·ã¼ãããªãå ´å㯠true
ãè¿ãã¾ãããã以å¤ã®å ´å㯠false
ãè¿ãã¾ãã ãã®å¤ã¯æ¢å®ã§ã¯ false
ã§ãï¼é¢é£ä»ããããã¹ã¿ã¤ã«ã·ã¼ããããå ´åï¼ã
ãã®ããããã£ã使ç¨ãã¦ãé¢é£ä»ããããã¹ã¿ã¤ã«ã·ã¼ããæå¹ã¾ãã¯ç¡å¹ã«ãããã¨ãã§ãã¾ãã é¢é£ä»ããããã¹ã¿ã¤ã«ã·ã¼ãããªãå ´åããã®ããããã£ã true
ã«è¨å®ãã¦ã广ã¯ããã¾ããã
ãã®ä¾ã¯ãHTML ã® <style>
è¦ç´ ã使ç¨ã㦠HTML ã§å®ç¾©ããã¹ã¿ã¤ã«ã«ãããã°ã©ã ãã disabled ããããã£ãè¨å®ãã¦ãã¾ãã ã¾ããDocument.styleSheets
ã使ç¨ãã¦ãææ¸å
ã®ãã¹ã¦ã®ã¹ã¿ã¤ã«ã·ã¼ãã«ã¢ã¯ã»ã¹ãããã¨ãã§ãã¾ãã
ãã® HTML ã«ã¯ã段è½è¦ç´ ãéããã HTML ã® <style>
è¦ç´ ãæ®µè½è¦ç´ ãã¹ã¿ã¤ã«ãæå¹/ç¡å¹ã«ããããã«ä½¿ç¨ãããã¿ã³ãå«ã¾ãã¦ãã¾ãã
<button>æå¹å</button>
<style id="InlineStyle">
p {
color: blue;
}
</style>
<p>
ã¹ã¿ã¤ã«ãç¡å¹ã®å ´åãããã¹ãã¯é»ã表示ãããæå¹ã®å ´åã¯éã表示ããã¾ãã
</p>
<p></p>
JavaScript
ä¸è¨ã®ã³ã¼ã㯠style
è¦ç´ ã® id ã使ç¨ãã¦åå¾ããç¡å¹ã¨ãã¦è¨å®ãã¦ãã¾ãã SVG ãå®ç¾©ãã¦ããã¹ã¿ã¤ã«ããã§ã«åå¨ãã¦ããã®ã§ãããã¯æåããã¯ãã§ãã
const style = document.getElementById("InlineStyle");
style.disabled = true;
次ã«ããã¿ã³ã®ã¤ãã³ããã³ãã©ã¼ã追å ãã¦ãdisabled
ã®å¤ã¨ãã¿ã³ã®ããã¹ããåãæ¿ãã¾ãã
const button = document.querySelector("button");
button.addEventListener("click", () => {
style.disabled = !style.disabled;
const buttonText = style.disabled ? "æå¹å" : "ç¡å¹å";
button.innerText = buttonText;
});
çµæ
çµæã¯ä¸è¨ã®ããã«è¡¨ç¤ºããã¾ãã ãã¿ã³ãæ¼ãã¨ã段è½ããã¹ãã«ä½¿ç¨ããã¹ã¿ã¤ã«ã® disabled
ããããã£å¤ãåãæ¿ããã¾ãã
ãã®ä¾ã¯ä¸ã®ä¾ã¨ã¨ã¦ãä¼¼ã¦ãã¾ãããã¹ã¿ã¤ã«ãããã°ã©ã ã§å®ç¾©ãã¦ããç¹ãç°ãªãã¾ãã
HTMLHTML ã¯ååã®å ´åã¨ä¼¼ã¦ãã¾ãããå®ç¾©ã«ã¯æ¢å®ã®ã¹ã¿ã¤ã«ãå«ã¾ãã¦ãã¾ããã
<button>æå¹å</button>
<p>
ã¹ã¿ã¤ã«ãç¡å¹ã®å ´åãããã¹ãã¯é»ã表示ãããæå¹ã®å ´åã¯éã表示ããã¾ãã
</p>
<p></p>
JavaScript
æåã« HTML ã«æ°ããã¹ã¿ã¤ã«è¦ç´ ã使ãã¾ãã ããã¯ãæåã« Document.createElement()
ã使ç¨ãã¦ã¹ã¿ã¤ã«è¦ç´ ã使ããã¹ã¿ã¤ã«å®ç¾©ã®ããã¹ããã¼ãã使ãã¦è¿½å ããã¹ã¿ã¤ã«è¦ç´ ãææ¸æ¬ä½ã«è¿½å ãããã¨ã«ãã£ã¦è¡ããã¾ãã
// `style` è¦ç´ ãçæ
const style = document.createElement("style");
const node = document.createTextNode("p { color: blue; }");
style.appendChild(node);
document.body.appendChild(style);
次ã«ãä¸è¨ã®ããã«ã¹ã¿ã¤ã«è¨å®ãç¡å¹ã«ãã¾ãã ãªãããããããããã£ã true
ã«è¨å®ããã®ã«æåããæãæ©ãã¿ã¤ãã³ã°ã§ãã ãã®ç¹ããåã¯ææ¸ã«ã¹ã¿ã¤ã«ããªãã®ã§ãæ¢å®å¤ã® false
ã«ãªãã¾ãã
//ã¹ã¿ã¤ã«ã®ç¡å¹å
style.disabled = true;
æå¾ã«ãç¡å¹ç¶æ ã¨ãã¿ã³ããã¹ããåãæ¿ãããã¿ã³ç¨ã®ã¤ãã³ããã³ãã©ã¼ã追å ãã¾ãï¼ããã¯ååã®ä¾ã¨åãã§ãï¼ã
const button = document.querySelector("button");
button.addEventListener("click", () => {
style.disabled = !style.disabled;
const buttonText = style.disabled ? "æå¹å" : "ç¡å¹å";
button.innerText = buttonText;
});
çµæ
çµæã¯ä¸è¨ã®ããã«è¡¨ç¤ºããã¾ãã ãã¿ã³ãæ¼ãã¨ãããã¹ãã«ä½¿ç¨ããã¹ã¿ã¤ã«ã® disabled
ã®ç¶æ
ãåãæ¿ããã¾ãã
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4