How to hide parts of HTML when JavaScript is disabled?

后端 未结 8 2117
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 06:10

I\'m trying to accommodate users without JavaScript. (By the way, is it worth the effort nowadays?)

In one HTML file I\'d like part of it execute if scripts are on

8条回答
  •  我寻月下人不归
    2021-02-07 06:35

    You could edit the HTML of the page with Javascript

    document.querySelector('div').style.display = 'block';
    div {
      display: none;
    }
    Div
    Try it with JS and the without JS.

提交回复
热议问题