HTMLコード
<body>
<h1 align="center">Are you ready?</h1>
<h2 align="center">Just answer Yes or No!</h2>
<div class="wrapper">
<button id="ohyes" class="buttonYes"> Yes </button>
<button id="ohno" class="buttonNo"> No </button>
</div>
</body>
Jクエリコード
<script>
$(function () {
$("#ohno").on({
mouseover: function () {
$(this).css({
left: (Math.random() * 800) + "px",
right: (Math.random() * 800) + "px",
top: (Math.random() * 400) + "px",
});
}
});
$("#ohyes").click(function () {
alert("yes"); //use .val() if you're getting the value
});
});
</script>
最初にjqueryで関数を呼び出そうとしていますが、マウスオーバーでボタンが動いていますが、IDがohyesのボタンをクリックしてもアラートボックスが表示されませんか? 助言がありますか?