LoginSignup
0
0

More than 3 years have passed since last update.

押すと色が変わるボタンの作り方を教えてください

Posted at

初めましてプログラミング初心者です

個人アプリ作成しています

ボタンが押されたときにボタンの色が変わるように実装しています

教えていただける方いましたらお願いします

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;
}

0
0
1

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
0