formater stringen

This commit is contained in:
Geir Okkenhaug Jerstad 2024-08-23 14:11:40 +02:00
parent b5a58f8cc6
commit daf0964cce

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Formater stringen</title>
</head>
<body>
<input type="text" id="string" onchange="formatString()">
<div>Med stor bokstav</div>
<div id="new"></div>
<script>
function formatString(){
let string = document.getElementById('string').value;
console.log(string)
let newString = string.charAt(0).toUpperCase() + string.slice(1);
document.getElementById('new').innerHTML = `${newString}`;
}
</script>
</body>
</html>