JSFiddle - React, Tailwind, and code Playground

by urashita

HTML

マウスオーバーで赤色
<br>
マウスのプッシュで青色
<br>

<body>
    <div id="btn1" class="button" href="#" ontouchstart="">ボタン1</div>
    <br>
    <div id="btn2" class="button" href="#" ontouchstart="">ボタン2</div>
</body>

CSS

.button {
    display: inline-block;
    padding: 5px 10px;
    background-color: green;
    color: white;
    border: 1px solid;
    text-decoration: none;
    font-size: 20px;
}

.button:hover {
    background-color: red;
    cursor: pointer;
}

.button:active {
    background-color: blue;
}

JavaScript

$('#btn1').on('click',function() {
  window.alert('ボタン1が押された');
});

$('#btn2').on('click',function() {
  window.alert('ボタン2が押された');
});