\r\n\r\n

javascriptでボタンの色を変更する方法(change button color in javascript)

このwikihowの記事では、javascriptを使用して、クリックされた後にボタンの色を変更する方法について説明します。ボタンの色を変えることで、ユーザーがページ上のボタンをクリックしたことを知らせることができます...

ステップス

  1. 1 Java編集環境でプロジェクトを開きます。これはVisualStudioやOracle JDeveloperのようなものでも良いのです。
  2. Image titled 12779919 1
  3. 2 次のコードをプログラムに入力し、onclickでボタンの色を変更します: < script> document getElementById("changeGreen").onclick=function(){document.getElementById("output").style.color='green';}document getElementById("changeRed").onclick=.function(){document.getElementById("output").style.color='red';}&lt/script> このコードは、テキストの色を緑から赤に変更するようボタンに促します。これらの色は、お好みの色に置き換えることができます。
  4. Image titled 12779919 2
  5. 3 テキストフィールドに入力する際のボタンの色を変更するには、次のコードをプログラム内に入力してください: <!DOCTYPE html&gt&书信电报;html lang="en"&gt&書信电报&gt&書信电报&meta charset=。「UTF-8" よりも大きい &copy telegram; meta name="viewport" content="width=device width, initial scale=1.0"&gt&lettergram;title>document&lt/header&gt&lettergram;link rel="stylesheet "href="//code.jquery.com/ui/1.12.1/themes/base/jquery ui.css"&gt &书信电报;script src="https://code.jquery.com/jquery-1.12.4.js"></script><script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js链接https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>>><body><label> username:</label>< input type="text "id="changecordemo "style="."margin left:10px; top of margin: 10px" on keyup="changethecolorRofButtonDemo()"><br&gt。<br>< button id="buttonDemo" style="background: sky blue; left margin: 10px;"> press me</button></jabody>< script> function changeColorDemo() {if (document.getElementById("changeColorDemo").value!==)"{document.getElementById("buttonDemo").style.background="green"."その他{document.getElementById("buttonDemo").style.background="skyblue"; }&lt/script&gt&lt/html> < if/otherwise> を使うと、入力欄が埋まるまでボタンが空色で、その後緑色のボタンに変わります。色を変更したい場合は、「グリーン」や「スカイブルー」などの色名、16進数(16進数カラーで検索すると出てきます)、RGBカラー(これもインターネットで検索すると出てきます)を使用します。コード内の色を変更するには、コードスタイル内の "green "と "sky blue "を置き換えてください。背景がない
  6. Image titled 12779919 3
  • 2022-03-13 08:19 に公開
  • 閲覧 ( 89 )
  • 分類:IT

あなたが興味を持っているかもしれない記事

匿名者
匿名者

0 件の投稿

作家リスト

  1. admin 0 投稿
  2. 匿名者 0 投稿

おすすめ