LoginSignup
0
1

More than 3 years have passed since last update.

入力フォームの文字の色を変える方法

Last updated at Posted at 2020-08-15

完成版

スクリーンショット 2020-08-15 9.54.30.png

作成

使用環境: HTML5 Bootstrap4

index.html

   <!--文字変更ボタン-->
    <button onclick="document.execCommand('bold');">太字</button>
    <button onclick="document.execCommand('italic');">斜め文字</button>
    <button onclick="document.execCommand('formatBlock', false, '<h1>')">h1</button>
    <button onclick="document.execCommand('formatBlock',false, '<p>')">p</button>

    <!--色変更ボタン-->
    <button onclick="document.execCommand('foreColor', false, 'red');"></button>
    <button onclick="document.execCommand('foreColor', false, 'blue');"></button>
    <button onclick="document.execCommand('foreColor', false, 'yellow');">黄色</button>
    <button onclick="document.execCommand('foreColor', false, 'green');"></button>
    <button onclick="document.execCommand('foreColor', false, 'black');"></button>

 <!--入力フォーム-->
  <div id="editor" contenteditable></div>

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1