<!-- clickイベント -->
<div class="event">
<h1 class="event_title">click</h1>
<button type="button" name="button" class="button_click">click me</button>
</div>
html{
font-size: 62.5%;
font-family: "Yu Gothic Medium", "游ゴシック Medium", "YuGothic", "游ゴシック体", "ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro", "メイリオ", "Meiryo", sans-serif;
letter-spacing: 0.1em;
color: #222;
}
button, input{
background-color: transparent;
border: none;
cursor: pointer;
outline: none;
padding: 0;
appearance: none;
appearance: none;
display: block;
}
.event{
width: 400px;
margin: 30px auto;
}
.event_title{
font-size: 2rem;
padding: 0.8rem 0 1rem 2rem;
background: #222;
color: #fabe00;
display: block;
}
/* clickイベント */
.button_click{
display: block;
width: 200px;
margin: 60px auto 100px;
background: #eee;
padding: 1.5rem 0;
border-radius: 10px;
font-size: 1.8rem;
font-weight: bold;
}
.button_click.active{
background: #cd0505;
color: #fff;
}
// clickイベント
$('.button_click').on('click', function(){
//activeクラスの切り替え
$(this).toggleClass('active');
});
This Pen doesn't use any external CSS resources.