Im trying to do one of my first websites in html, javascript and css and im having lots of questions! I have this code:
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">
<link href="styles.css" rel="stylesheet">
<title>Mercedes Benz Dealership</title>
</head>
<body>
<div id="result1">
**<h2> Good day Buyer!</h2>**
</div>
<form onsubmit="greet(); return false">
<input type ="text" id="name">
<input type="submit">
</form>
</body>
<script>
function greet()
{
var name = document.querySelector("#name").value;
if (name!=="")
{
document.querySelector("#result1").innerHTML ="Good day, " + name;
}
}
</script>
</html>
I want the format of the text in:
document.querySelector("#result1").innerHTML ="Good day, " + name;
To be the same of :
<h2> Good day Buyer!</h2>
The title is the same one! but when the user inputs the name the only difference should be "Good day,Alan" for example with the same bold, letter size and everything of the h2 title!
How can i achieve that?? I have been trying to do it with no success.
Thanks a lot for the help!! really