こんにちは、私はこの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>