Reputation: 1789
Im trying to send an ajax request only if a input is not disabled. So does not have disabled="disabled"
property.
Here is the jquery code:
if ($('#field_22Travel').not(':disabled')) {
//send ajax request
sendAjaxPrefs(catTag, remTag, unsubscribeTag, subscribeFlag);
}
Here is the html input:
<input id="field_22Travel" class="check-box" name="field_22Travel" value="Travel" disabled="disabled" type="checkbox">
I'm sure it's something simple I'm missing just not sure what. Cheers
Upvotes: 0
Views: 2795
Reputation: 2570
Try it with the is() method.
if (!$('#field_22Travel').is('[disabled=disabled]')) {
alert("hello")
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="btn button" id="field_22Travel" disabled="disabled"></button>
Upvotes: 2
Reputation: 9808
you can use prop()
which simply returns a Boolean, something like this:
if (!$('#field_22Travel').prop('disabled')) {
//send ajax request
sendAjaxPrefs(catTag, remTag, unsubscribeTag, subscribeFlag);
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="btn button" id="field_22Travel" disabled="disabled"></button>
Upvotes: 2