I have a table with user interaction controls in its cells (button, link, etc.) and I want to "grayed" some rows of that table so all operations of these rows will be disabled.
Any idea what's the best way to do this in Javascript?
I have a table with user interaction controls in its cells (button, link, etc.) and I want to "grayed" some rows of that table so all operations of these rows will be disabled.
Any idea what's the best way to do this in Javascript?
Using jQuery, this sets the disabled property on <input>
and <button>
tags, which disables them:
$("#row_id input, #row_id button").prop('disabled', true);
Where row_id is the id of the row that has controls you want to disable.
For links, this makes it so that when they are clicked, nothing will happen:
$("#row_id a").click( function (e) {
e.preventDefault();
} );
You probably also want to add some classes to them so you can style them differently. Just ask if you want to know how to do that.
There is a related question on disabling links at jQuery disable a link