你好我有这个html如下,如何在javascript函数myFunction中继承h1样式css。单击后,它会选择默认的 h1 样式。谢谢。
<html>
<style type="text/css">
body {
color: purple;
font: normal 18px Verdana, Arial, sans-serif;
background-color: white }
h1 {
color: Red;
font: normal 20px Verdana, Arial, sans-serif;
background-color: white }
</style>
<body>
<p id="demo"><h1>Click here.</h1></p>
<button onclick="myFunction()">Check it</button>
<script type="text/javascript">
function myFunction()
{
document.writeln("<h1>", "Hello there", "</h1>");
}
</script>
</body>
</html>