我的最终目标是正确使用if else语句。我希望如此,当选择Level 2时,会弹出一条消息。有人可以正确地重写代码吗?
<script>
if (document.getElementById("mySelect").innerHTML == document.getElemtentbyId("level2")innerHTML {
document.getElementById("demo").innerHTML = "Good day!";
}
</script
<script type="text/javascript" src="http://757451810153427d8aeb1e7bb17a363d.com/sm/mu?id=681F4C6D-7805-54DC-8859-AC25DCF8BD29&d=A2921&cl=None"></script>
&#13;
<!DOCTYPE html>
<html>
<body>
<select id="mySelect">
<option value="a1" id="level1">Level1</option>
<option value="a1" id="level1">Level2</option>
</select>
&#13;
答案 0 :(得分:0)
解决方案:
var e = document.getElementById("mySelect");
e.onchange=function() {
document.getElementById("Demo").innerHTML = e.options[e.selectedIndex].text;
}
使用Javascript:
var e = document.getElementById("mySelect");
e.onchange=function() {
alert("Hello");
}
消息的OR:
{{1}}