押すと色が変わるボタンの作り方を教えてください
639 ワード
初めましてプログラミング初心者です
個人アプリ作成しています
ボタンが押されたときにボタンの色が変わるように実装しています
教えていただける方いましたらお願いします
haml
%input{type: "button", value: "12", class: "btn"}
js
$(function(){
$('.btn').on('click', function(event){
event.preventDefault();
$(this).toggleClass('active');
});
});
scss
input{
width: calc(100% / 5);
height: 40px;
color:whitesmoke;
margin-left: 8px;
.btn.active{
color: red;
background-color: red;
}
Author And Source
この問題について(押すと色が変わるボタンの作り方を教えてください), 我々は、より多くの情報をここで見つけました https://qiita.com/D41En/items/480aec78479c591244c8著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .