我正在尝试使用 Joomla 中的 Jumi 模块显示图像。目前,脚本正在调用附加到 body 标记,但这会将图像放在模板的底部。我需要能够在不附加到正文的情况下运行我的脚本,但不能只调用该函数,因为我的脚本使用 if else 语句来确定要做什么。我对 JS 很陌生,但是有没有办法附加到段落标签或 div 中?
<script>
function show_image(src, width, height, alt) {
var img = document.createElement("img");
img.src = src;
img.width = width;
img.height = height;
img.alt = alt;
document.body.appendChild(img);
}
var month = new Date().getMonth();
var time = new Date().getHours();
var day = new Date().getDay();
if (month > "3" && month < "10" && day == "6" && time > "19" && time <= "22") {
show_image("http://bizeebee.com/wp-content/uploads/2013/07/open-sign.jpg",500,450, "Powell is OPEN");
}
else { show_image("http://get.whotrades.com/u3/photoBB09/20171363290-0/blogpost.jpeg",500,450, "Powell is CLOSED");}
</script>