Reputation: 187
I have a button created in ajax event (I call some data and I create a button at the end).
How do I disable it?
I try:
$(document).on("click", ".sendLead", function(event) {
$(".sendLead").disabled = true;
some code...
but it does not work !
Any idea ?
Upvotes: 2
Views: 5593
Reputation: 4315
disabled
is a boolean attribute that you have to set with the prop()
method or the attr()
method on your element. So simply try:
$('.sendLead').click(function(event) {
$(".sendLead").prop('disabled', true);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="sendLead">Click</button>
Upvotes: 2
Reputation: 1297
Try this
$(document).on("click", ".sendLead", function(event) {
$(".sendLead").prop("disabled", true);
Upvotes: 1
Reputation: 1633
use attr
function in jQuery
replace
$(".sendLead").disabled = true;
with
if you are using jQuery 1.6 or prior use
$('.sendLead').attr('disabled',true);
or
$('.sendLead').attr('disabled','disabled');
after jQuery 1.6 use
$('.sendLead').prop('disabled',true);
Upvotes: 2