【发布时间】:2020-03-10 21:50:51
【问题描述】:
So basically what I want here is to create a hidden paragraph and when each value is selected the hidden paragraph shows the custom text I set up for each value .所以基本上如果我选择奥迪我想输入:随机文本/宝马>随便/梅赛德斯>汽车,
重点是为每个选定的值自定义其显示的文本
完全需要这个,所以任何帮助都非常感激!
<!DOCTYPE html>
<html>
<body>
<p>Select a new car from the list.</p>
<select id="mySelect" onchange="myFunction()">
<option value="Audi">Audi
<option value="BMW">BMW
<option value="Mercedes">Mercedes
<option value="Volvo">Volvo
</select>
<p>When you select a new car, a function is triggered which outputs the value of the selected car.</p>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("mySelect").value;
document.getElementById("demo").innerHTML = "You selected: " + x;
}
</script>
</body>
</html>
【问题讨论】:
-
你为什么不把你想要的每个车名的文本作为值?
-
因为我不知道该怎么做哈哈
标签: javascript html css