Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to disable and enable HTML table using javascript?
    primarykey
    data
    text
    <p>I want to know how can I disable and enable the highlighting on an HTML table using javascript by clicking an html button.</p> <p>Here are my codes:</p> <p><b><code>tabletest.html</code></b></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function disableTable() { document.getElementbyId('tblTest').disabled = true; } function enableTable() { document.getElementbyId('tblTest').disabled = false; } &lt;/script&gt; &lt;style type="text/css"&gt; table#tblTest { width: 100%; margin-top: 10px; font-family: verdana,arial,sans-serif; font-size:12px; color:#333333; border-width: 1px; border-color: #666666; border-collapse: collapse; } table#tblTest tr.highlight td { background-color: #8888ff; } table#tblTest tr.normal { background-color: #ffffff; } table#tblTest th { white-space: nowrap; border-width: 1px; padding: 8px; border-style: solid; border-color: #666666; background-color: #dedede; } table#tblTest td { border-width: 1px; padding: 8px; border-style: solid; border-color: #666666; background-color: #ffffff; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;table id="tblTest"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Address&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'" &gt; &lt;td&gt;Tom&lt;/td&gt; &lt;td&gt;UK &lt;/td&gt; &lt;/tr&gt; &lt;tr onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'" &gt; &lt;td&gt;Hans&lt;/td&gt; &lt;td&gt;Germany&lt;/td&gt; &lt;/tr&gt; &lt;tr onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'" &gt; &lt;td&gt;Henrik&lt;/td&gt; &lt;td&gt;Denmark&lt;/td&gt; &lt;/tr&gt; &lt;tr onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'" &gt; &lt;td&gt;Lionel&lt;/td&gt; &lt;td&gt;Italy&lt;/td&gt; &lt;/tr&gt; &lt;tr onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'" &gt; &lt;td&gt;Ricardo&lt;/td&gt; &lt;td&gt;Brazil&lt;/td&gt; &lt;/tr&gt; &lt;tr onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'" &gt; &lt;td&gt;Cristiano&lt;/td&gt; &lt;td&gt;Portugal&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;input type="button" onclick="disableTable();" value="Disable" /&gt; &lt;input type="button" onclick="enableTable()" value="Enable" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Whenever I click the <code>Disable</code> button the table highlighting is still enabled. I'm kinda new to this so I really need your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload