我希望伯恩茅斯这个词是红色的,但其余的词要从 p 样式继承。
<script type="text/javascript">
$(document).ready(function() {
var now = new Date();
var hours = now.getHours();
var msg;
if (hours >= 0 && hours <= 12) msg = "Today's lunch deals in Bournemouth";
else if (hours >= 13 && hours <= 19) msg = "Tonight's dinner deals in Bournemouth";
else msg = "Tomorrow's lunch deals in Bournemouth";
$('#time p').text(msg);
});
</script>
<div id="time" style="position:absolute; width:100%; padding-top:90px; text-align:center; font-family: Arial, Helvetica, sans-serif; font-weight:bold; color:#FFF; font-size:17px;">
<p></p>
</div>
我需要为 jQuery 颜色使用某些标签吗?我尝试了 HTML,但这只是打印出代码。