Reputation: 3502
here is the my code;
Loading data from database my buttons,after loading finished,I want to trigger some client script,.in my senario,after clicked the first button ,want to disable clicked button, and enable the secon button(clickable element) I am able to disabled fisrt button, I couldnt enable secont button though **
First button
<button type="button" class="btn btn-default"
onclick="
var resetbtnid = '#m-' + $(this).attr('id'); //I am getting
$(this).prop('disabled', true);
$('#resetbtnid').removeAttr('disabled');
"
name='<%# DataBinder.Eval(Container.DataItem,"Fiyat") %>'
id='<%# DataBinder.Eval(Container.DataItem,"Id") %>' >
<span class="glyphicon glyphicon-ok-sign"></span></button>
Second button
<button type="button" disabled="disabled" class="btn btn-default"
id='m-<%# DataBinder.Eval(Container.DataItem,"Id") %>'
name='<%# DataBinder.Eval(Container.DataItem,"Fiyat") %>' >
<span class="glyphicon glyphicon-minus-sign"></span></button>
Upvotes: 1
Views: 141
Reputation: 4079
When there are two buttons, one is enabled (default), the second is disabled, it looks like this in code
HTML:
<button id="btn1" />
<button id="btn2" disabled="disabled" />
JS:
$(document).ready(function() {
$('#btn1').click(function () {
$('#btn1').prop('disabled', 'disabled');
$('#btn2').prop('disabled', false);
})
})
That should do the job!
Upvotes: 1
Reputation: 133403
Your selector is incorrect. In your code $('resetbtnid').removeAttr('disabled')
Use #
if you want ID selector like $('#resetbtnid').removeAttr('disabled')
You can use .prop()
like $('#resetbtnid').prop('disabled', true/false)
Use .
for class selector.
EDIT:
As resetbtnid
is a variable use it without quotes
var resetbtnid = '#m-' + $(this).attr('id');
$(resetbtnid).removeAttr('disabled');
Upvotes: 3
Reputation: 3965
Try this:
//Enable
$('#buttonID').attr('disabled', 'disabled');
//Disable
$('#buttonID').removeAttr('disabled');
Upvotes: 1