当按钮被点击时,我想改变按钮“游戏添加”的背景颜色。当在叠加中点击“X”时,我想要将它改回原来的颜色。这是我的代码更改背景颜色的按钮点击
$('.game-add').click(function() {
$(".game-add").css("background-color","5da93c");
$('#overlay').toggleClass('active');
// calcs bottom of button
var bottom = $(this).position().top + $(this).outerHeight(true);
$('#overlay').css({
'top': bottom + 'px',
});
});
$('#close').click(function(){
$(".game-add").css("background-color","1D1D1D");
$('#overlay').removeClass('active');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" class="btn btn-link game-add">ADD GAME</button>
<div id="overlay">
<a href="#" id="close" class="pull-right" style="color: #fff;">X</a>
<h2>This is an overlay</h2>
</div>
任何帮助将大大赞赏。谢谢
你能告诉我们目前的问题是什么? – urielSilva
根本不会改变颜色 –