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
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>
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.