因此,如果为此提供适当的标题,我会遇到一些麻烦,所以请在输入时纠正我的错误。将图片和文字设为默认
点击我的问题(我添加了一张图片以供澄清)当我点击按钮1时,图片将显示在左侧,文本将显示在中间。如果点击按钮2,新图片将显示在左侧,并且新的文本将显示在中间。
所以我的问题是:如何将按钮1设置为默认值,以便在加载网站时显示与该按钮相关的图片和文本。即时通讯新的JS,所以请详细解释。谢谢。 ![[
function changeText(value) {
var div = document.getElementById("div");
var text = "";
var image = "";
if (value == 1) text += "<span class='custom_text_h_w'>this is picture one</span> <br> <img class='custom_h_w' src='images/consumers_1.png'/>";
if (value == 2) text += "<span class='custom_text_h_w'>this is picture two</span> <br> <img class='custom_h_w' src='images/consumers_2.png'/>";
if (value == 3) text += "<span class='custom_text_h_w'>this is picture tree</span> <br> <img class='custom_h_w'src='images/consumers_3.png'/>";
div.innerHTML = text;
}
.custom_h_w{
top: 1700px;
left: 100px;
height:456px;
width: 342px;
position: absolute;
}
.custom_text_h_w{
top: 1700px;
right: 800px;
position: absolute;
}
<a href="javascript: changeText(1);">
<img id="searchconsumers" src="images/search.png" width="60px" height="60px" alt="abc" />
</a>
<a href="javascript: changeText(2);">
<img id="exploreconsumers" src="images/explore.png" width="60px" height="60px" top="1700px" right="700px" alt="abc" />
</a>
<a href="javascript: changeText(3);">
<img id="funconsumers" src="images/fun.png" width="60px" height="60px" alt="abc" />
</a>
<div id="div"></div>
<体的onload = “changeText(1);”>一团糟我的一些其它码和document.addEventListener( 'DOMContentLoaded',函数(){ changeText(1); }你也有同样的建议吗?你有其他建议吗? –