我想要在某些特定的日子里弹出警报,但似乎无法通过
$(document).ready(function () {
$days = ['Sunday', 'Monday', 'Tuesday', 'Wenesday', 'Thursday', 'Friday', 'Saturday'];
d = new Date(); //This returns Wed Apr 02 2014 17:28:55 GMT+0800 (Malay Peninsula Standard Time)
x = d.getDay(); //This returns a number, starting with 0 for Sunday
if ($days = 'Monday,Tuedsay') {
alert($days[x]);
}
});
答案 0 :(得分:2)
这应该有效
$(document).ready(function () {
$days = ['Sunday', 'Monday', 'Tuesday', 'Wenesday', 'Thursday', 'Friday', 'Saturday'];
d = new Date(); //This returns Wed Apr 02 2014 17:28:55 GMT+0800 (Malay Peninsula Standard Time)
x = d.getDay(); //This returns a number, starting with 0 for Sunday
if ($days[x] == 'Monday' || $days[x] == "Tuesday") {
alert($days[x]);
}
});
答案 1 :(得分:1)
试试这个,简单方法。
$(document).ready(function () {
$days = ['Sunday', 'Monday', 'Tuesday', 'Wenesday', 'Thursday', 'Friday', 'Saturday'];
d = new Date(); //This returns Wed Apr 02 2014 17:28:55 GMT+0800 (Malay Peninsula Standard Time)
x = d.getDay(); //This returns a number, starting with 0 for Sunday
if ($days[x] = ['Monday,Tuedsay']) {
alert($days[x]);
}
});