Home>

Please write your question in detail here.
html is rewritten using getElementsByClassName of Javascript.

Error message

I don't know the reason why I didn't rewrite.

No change
Applicable source code

<html>
<head>
<meta charset ="utf-8">
<meta robot ="noindex">
</head>
<body>
<div class ="wrap">
<div class ="div">
<p class ="div">aa 株式会社</p>
</div>
<span id ="corp">corporation aa</span>
<div class ="class"></div>
<button type ="button"onclick ="clicker ();"></button>
</div>
<script>
function clicker () {
var change = document.getElementsByClassName ('div');
change [0] .innerHTML ="aa Corporation is" ;;
}
</script>
</body>
</html>

html, javascript
Tried Supplemental information (FW/tool version etc.)

Please provide more detailed information here.

  • Answer # 1

    If you copy and paste the code, it worked.
    It may depend on the environment, but
    <div class ="class"></div>
    Since there is a full-width space in this part, how about changing to a half-width space?

  • Answer # 2

    Aside from the quality of the source, I think it works as a proposition for the time being.
    If it doesn't work, you should provide the OS and browser type and version

Related articles