Reputation: 979
My view page:
<td>@Html.CheckBoxFor(m => m.CheckedStatus, new Dictionary<string, object> { { "id", "cbCheckedStatus7" }, { "name", "cbCheckedStatus" },{"class","onchange"} })
</td>
<span id="spBlueCheckbox" style="display: none; color: blue;">
Jquery:
jQuery().ready(function domReady($) {
if ($('#cbCheckedStatus7').is(':checked')) {
$('#spBlueCheckbox').show();
} else {
$('#spBlueCheckbox').hide();
}
});
if i check the checkbox, no action is taken place, i mean the span tag should be shown, when checkbox is checked. Initially the span is not shown.
Upvotes: 0
Views: 43
Reputation: 318162
You'll need an event handler for that
jQuery(function($) {
$('#cbCheckedStatus7').on('change', function() {
$('#spBlueCheckbox').toggle(this.checked);
});
});
And where did you find that DOM ready handler?
Upvotes: 2