How to write this in a simpler less ridiculous way
Posted
by
Richard Knop
on Stack Overflow
See other posts from Stack Overflow
or by Richard Knop
Published on 2011-01-12T08:49:02Z
Indexed on
2011/01/12
8:53 UTC
Read the original article
Hit count: 235
JavaScript
|jQuery
This just seems absurd to me. Should I use array instead or is there some other better solution?
$('.hoursRange').change(function() {
if ('0' == $(this).val())
{
$(this).val('00');
return false;
}
if ('1' == $(this).val())
{
$(this).val('01');
return false;
}
if ('2' == $(this).val())
{
$(this).val('02');
return false;
}
if ('3' == $(this).val())
{
$(this).val('03');
return false;
}
if ('4' == $(this).val())
{
$(this).val('04');
return false;
}
if ('5' == $(this).val())
{
$(this).val('05');
return false;
}
if ('6' == $(this).val())
{
$(this).val('06');
return false;
}
if ('7' == $(this).val())
{
$(this).val('07');
return false;
}
});
© Stack Overflow or respective owner