-2

I have an html page with jquery that contains a table with buttons in a column as following. I need to disable all buttons with class Crem.

I have try the following but not working.

$(document).ready(function() {
     $( ".Crem" ).prop( "disabled", true);
}

<table id="settlementsd" class="table table-striped">
<thead>
</thead>
<tbody>
<tr>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th><button type="submit" id="stlmtdadd" class="Crem btn btn-sm btn-info" ><span class="glyphicon glyphicon-plus-sign"></span> </button></th>
</tr>
<tr>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th><button type="submit" id="stlmtdadd" class="Crem btn btn-sm btn-info" ><span class="glyphicon glyphicon-plus-sign"></span> </button></th>
</tr>
<tr>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th>&nbsp;</th>
  <th><button type="submit" id="stlmtdadd" class="Cadd btn btn-sm btn-info" ><span class="glyphicon glyphicon-plus-sign"></span> </button></th>
</tr>

</tbody>
<tfoot>
</tfoot>
</table>
Giorgos
  • 535
  • 2
  • 10
  • 25

2 Answers2

0

Buttons are simple to disable as disabled is a button property which is handled by the browser:

<button class="btn" disabled>My Button</button>

To disable these with a custom jQuery function, you'd simply make:

p.s You are missing brackets and semicolon at the end of function

  $(document).ready(function() {
     $(".Crem").prop('disabled',true);
  });

Here is a working jsfiddle

Edison Biba
  • 3,906
  • 2
  • 11
  • 30
0

don't use same id for single. one page must contain a single unique id. your are repeating id="stlmtdadd". here is your working Demo: https://jsfiddle.net/aL4xLm6a/`

$(document).ready(function() {
     $( ".Crem" ).each(function(){
           $(this).prop('disabled',true);

     });
});