我试图根据给定的日期连续单击按钮来获取最近的星期三或/然后星期六的日期。我怎样才能做到这一点?
$(".btn-info").on("click", function(){
GetDate('2019-09-10');
});
function GetDate(x){
x = new Date();
var cc = x.setDate(x.getDate() + (1 + 5 - x.getDay()) % 7);
console.log(cc);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<button type="button" class="btn btn-info">Get Next Wednesday / Saturday Date ++ </button>
吃鸡游戏
相关分类