Reputation: 2177
In my JQuery mobile application, I have an anchor button. It should be disabled at first and on checking the check box, able the anchor button. But it is not working.
Html code is
<input type="checkbox" name="checkbox2" id="checkbox2" class="custom" />
<div id="check">
<a data-role="button" data-transition="fade" data-theme="c" disabled="disabled" onclick="PostRegistration()" class="forcolouredbuttontext">
REGISTER
</a>
</div>
Script is
$('#check').ready(function(){
$('#checkbox2').click(function() {
var buttonsChecked = $('input:checkbox:checked');
if (buttonsChecked.length) {
$('div#check a').button('enable');
}
else {
$('div#check a').button('disable');
}
});
});
What am i doing wrong here?
Please help,
Thanks
Upvotes: 1
Views: 4326
Reputation: 55750
disabled="disabled"
is used for input controls. You cannot disable the anchor tag.
Try using a button element instead..
<input type="checkbox" name="checkbox2" id="checkbox2" class="custom" />
<div id="check">
<input type="button" data-role="button" data-transition="fade" data-theme="c" disabled="disabled" onclick="PostRegistration()" class="forcolouredbuttontext" value="REGISTER" />
</div>
//
$('#check').ready(function(){
$('#checkbox2').click(function() {
var buttonsChecked = $('input:checkbox:checked');
if (buttonsChecked.length) {
$('div#check input[type=button]').attr('disabled', false);
}
else {
$('div#check input[type=button]').attr('disabled', true);
}
});
});
Upvotes: 1
Reputation: 5356
<a data-role="button" data-transition="fade" data-theme="c" disabled="disabled" onclick="PostRegistration()" class="forcolouredbuttontext" id="checkbox2">
Upvotes: 0