There is such a column
<td id="sex">@person.Sex</td> Output there is 0 or 1 or even empty. What function should I write to replace, for example, 0 with the string "zero", 1 with the string "one", and the emptiness with "empty".
@person.Sex Output there is 0 or 1 or even empty. What funct...">
There is such a column
<td id="sex">@person.Sex</td> Output there is 0 or 1 or even empty. What function should I write to replace, for example, 0 with the string "zero", 1 with the string "one", and the emptiness with "empty".
Made a div instead of td ... But the principle does not change :)
$('.sex').each(function() { switch ($(this).html()) { case '0': $(this).html('ноль'); break; case '1': $(this).html('единица'); break; default: $(this).html('пусто'); break; } }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="sex">1</div> <div class="sex">0</div> <div class="sex"></div> <div class="sex">1</div> <div class="sex">0</div> id="sex" , however id should be unique on the page. You should change the id to class . I changed the answer - look. - cyadvertSource: https://ru.stackoverflow.com/questions/500765/
All Articles