I use the following button.
<input type="button" id="attractionsSection" value="Warsztaty" onclick="location.href='@Url.Action("AddAttractions","ReservationDetails")'" disabled="disabled" />
In js script i check wheather some condition is true and then I set property disabled of button.
if(Model.stagesConfirmation[4]==true)
{
<script>
$(function () {
console.log('Test1');
document.getElementById('attractionsSection').disabled = 'true';
console.log(document.getElementById('attractionsSection'));
console.log('Test2');
});
</script>
}
I use console log to test wheather this condition is passed and that is OK. I set disabled and button still remains active. This console.log
console.log(document.getElementById('attractionsSection'));
shows me the following thing
<input type="button" id="attractionsSection" value="Warsztaty" onclick="location.href='@Url.Action("AddAttractions","ReservationDetails")'"/>
So it is not disabled. How to solve, what can be the problem?
See this answer . You need to use element.removeAttribute("disabled");
or element.disabled = false;
You don't say disabled=true
you just say disabled
. Check here for documentation on the disabled
attribute.
You could say disabled="foobar"
and it will still disable the button. To prove that, play around with this .
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.