1

I want to disable the image button inside the anchor tag using jQuery. my requirement is, the button should be disabled before filling the all form fields.

<form name="signupFrm" id="signupFrm">
 <input type="text" />
 <a href ="javascript:void(0)" class="btnspc1 continueBtn submit"> <img src="images/continue-button.png" alt="jio money"/></a>
</form>

I tried in the following way, but no luck

$form = $('#signupFrm'); // cache
$form.find('a.submit img').prop('disabled', true); // disable submit btn
vishnu
  • 4,377
  • 15
  • 52
  • 89

2 Answers2

3

To give the button a disabled look, you can use this CSS:

.disabled {
    opacity: 0.4;
    filter: alpha(opacity=40); /* msie */
}

and then apply the style to you button like so:

$('a.submit img').addClass("disabled");

and remove this like so:

$('a.submit img').removeClass("disabled");

Demo: JSBin

Drakes
  • 23,254
  • 3
  • 51
  • 94
1

there is no direct disabled option for an img, you should program with 2 images, 1 with bit greyed color another with bright color and you should program the click event to return false and preventDefault() like that

Duplicate: Gray out image with CSS?

Duplicate: How can I disable the color of an image using css?

Duplicate: How do you make an anchor link non-clickable or disabled?

Community
  • 1
  • 1
Dickens A S
  • 3,824
  • 2
  • 22
  • 45