JSFiddle - React, Tailwind, and code Playground

by kazumasa sait

HTML

<h1 id="mainTitle">メイン見出し</h1>

<p class="textArea" >
何か文章文章文章、何か文章文章文章、何か文章文章文章、何か文章文章文章、何か文章文章文章、何か文章文章文章
</p>

JavaScript

var mainTitle = document.getElementById('mainTitle');

//中身のテキストを入れ替える
//mainTitle.innerHTML = '変換された見出し';

//テキストを追加してみる
var txt = document.createTextNode('追加した文章');
mainTitle.appendChild(txt);

//文章を右揃えにする
//classなどは複数存在可なので、配列指定をしてから変数に代入する
var textArea = document.getElementsByClassName('textArea')[0];
textArea.setAttribute('align','right');