Padmaja
Padmaja

Reputation: 119

How to disable image buttons in jquery?

Following is the requirement :

  1. Table contains many rows.Each row has edit and remove icons.
  2. When user clicks on one edit/delete icon in one row then all edit and delete icons in all the rows of the table has to be disabled.
  3. On click of edit icon javascript function called to open a popup with values of the corresponding row. On click of delete icon form submit happens.

Following is the code:

<td style="text-align:center;"><input
    onclick="clearMessage()"
    type="image"
    src="/images/pen_edit_thick.png"
    class="imgEditPen"
    title="<bean:message key="button.tooltip.edit"/>"></td>
<td style="text-align:center;"><input
    onclick="clearMessage();"
    type="image"
    src="/images/icon_delete.gif"
    class="imgEditPen"
    title="<bean:message key="button.tooltip.remove"/>"></td>

Tried following methods : Using button selector with disabled property ($(':button').prop('disabled', true); // Disable all the buttons .But that doesnt seem to work. Kindly help.

Upvotes: 0

Views: 641

Answers (1)

Piotr
Piotr

Reputation: 680

From the code I see, none of your input is button typed.

Try

$(":image").attr("disabled", "disabled")

or

$(":image").prop("disabled", true)

It will select image typed input and buttons

Upvotes: 1

Related Questions