サイズごとに2つのクラスを作成し、ボタンをクリックしてスワップします。 2つのスタイルのためのCSSは次のようになります。
.text-large {
font-size: 12px;
}
.text-small {
font-size: 9px;
}
ボタンは次のようになります。このJavaScriptを使用して
<button onclick="changeTextSize(false)">-</button>
<button onclick="changeTextSize(true)">+</button>
:
は情報不足でにテストしていません
function changeTextSize(toLarge) {
var articleText = document.getElementById('article-text'); //Or whatever the id is
if (toLarge) {
articleText.className = articleText.className.replace('text-small', 'text-large');
} else {
articleText.className = articleText.className.replace('text-large', 'text-small');
}
}
あなたの答えは私があなたの現在のコードがどのように見えるかを意味しません。
を説明するためにいくつかのコードを追加します。ありがとうございました! – Yovav