\r\n
\r\n
Toggle navigation
ホームページ
(current)
Q&A
投稿
トピック
検索
デフォルト
商業金融
汎用
言語
グルメ
ファッション
健康医療
化学
物理的
せいぶつ
科学
javascriptでボタンの色を変更する方法(change button color in javascript)
このwikihowの記事では、javascriptを使用して、クリックされた後にボタンの色を変更する方法について説明します。ボタンの色を変えることで、ユーザーがページ上のボタンをクリックしたことを知らせることができます...
ステップス
1 Java編集環境でプロジェクトを開きます。これはVisualStudioやOracle JDeveloperのようなものでも良いのです。
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';}</script> このコードは、テキストの色を緑から赤に変更するようボタンに促します。これらの色は、お好みの色に置き換えることができます。
3 テキストフィールドに入力する際のボタンの色を変更するには、次のコードをプログラム内に入力してください: <!DOCTYPE html>&书信电报;html lang="en">&書信电报>&書信电报&meta charset=。「UTF-8" よりも大きい © telegram; meta name="viewport" content="width=device width, initial scale=1.0">&lettergram;title>document</header>&lettergram;link rel="stylesheet "href="//code.jquery.com/ui/1.12.1/themes/base/jquery ui.css"> &书信电报;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>。<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"; }</script></html> < if/otherwise> を使うと、入力欄が埋まるまでボタンが空色で、その後緑色のボタンに変わります。色を変更したい場合は、「グリーン」や「スカイブルー」などの色名、16進数(16進数カラーで検索すると出てきます)、RGBカラー(これもインターネットで検索すると出てきます)を使用します。コード内の色を変更するには、コードスタイル内の "green "と "sky blue "を置き換えてください。背景がない
2022-03-13 08:19 に公開
閲覧 ( 89 )
分類:
IT
0 おすすめ
あなたが興味を持っているかもしれない記事
匿名者
0 件の投稿
作家リスト
admin
0 投稿
匿名者
0 投稿
おすすめ
×
プライベートメッセージを送信する
送る:
コンテンツ: