We would like to know how to capitalize first letter.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!-- w w w.ja v a 2s . c o m-->
var name = 'test';
function capital(str)
{
return str.charAt(0).toUpperCase() + str.slice(1);
}
document.writeln(capital(name));
}
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows: