使用内联JavaScript添加当前日期 [英] Add current date using inline javascript
本文介绍了使用内联JavaScript添加当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行以下代码时,日期未显示在输出中.我似乎无法弄清楚为什么日期不显示...
The date is not showing up in the output when I run the following code. I can't seem to figure out why the date won't show up...
<!DOCTYPE html>
<html>
<head>
<title>document.write() Example</title>
</head>
<body>
<p>The current date and time is:
<script type="text/javascript">
document.write("<strong>" + (new Date()).toString() + "</strong>");
</script>
</p>
</body>
</html>
推荐答案
因为您使用的是以下类型的引号:"..."
.您需要使用"..."
Because you are using these types of quotes: " ... "
. You need to use " ... "
<script type="text/javascript">
document.write("<strong>" + (new Date()).toString() + "</strong>");
</script>
摘要:
document.write("<strong>" + (new Date()).toString() + "</strong>");
这篇关于使用内联JavaScript添加当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文