How to disable and enable HTML table using Javascript?

前端 未结 10 1307
醉梦人生
醉梦人生 2020-12-11 18:04

I want to know how can I disable and enable the highlighting on an HTML table using Javascript by clicking an html button.

Here are my codes:

tabletest.ht

10条回答
  •  甜味超标
    2020-12-11 18:25

    Follow this recipe:

    Define two sets of CSS rules. One set of rules always starts with table.enabled, the other with table.disabled

    To enable/disable the whole table, locate the DOM element (using document.getElementbyId('tblTest') when the table has the id tblTest) and assign the respective class:

    document.getElementbyId('tblTest').classname = enabled ? 'enabled' : 'disabled';
    

提交回复
热议问题