永发信息网

js 根据月份显示不同内容

答案:1  悬赏:0  手机版
解决时间 2021-02-03 11:14
  • 提问者网友:杀手的诗
  • 2021-02-03 08:25
我想求一段js代码,js 根据单双月份显示不同内容。
比如:
1月份是单月,自动显示:单月;
2月份是双月,自动显示:双月;
3月份是单月,自动显示:单月;
.....
不知如何写才简洁呢?
谢谢!

想用到html页面里面的。
最佳答案
  • 五星知识达人网友:骨子里都是戏
  • 2021-02-03 09:27
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Ball</title>
<style type="text/css">
</style>
<script type="text/javascript">
var masanli = function (month)
{
return month % 2 === 0 ? "双月" : "单月"; 
}

</script>
</head>
<body>
<input type="text" id="txt" value="12" />
<button onclick="result.innerHTML = masanli(txt.value)">test</button>
<div id="result"></div>
</body>
</html>
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯