Javascript-使用表单select onChange创建新div

Javascript-使用表单select onChange创建新div,javascript,html,Javascript,Html,我很难从表单中使用javascript创建新的div。 我的html表单中有一个选择框 <select name="seasonSelector" id="seasonSelector" onchange="jsSeason('seasonWrapper')"> 我不确定我做错了什么,或者代码中没有包含什么 提前谢谢 x是选择元素,您希望读取其值: if (x.value == 2) { // ... } 还要注意,您应该使用比较运算符=而不是赋值= if (x.valu

我很难从表单中使用javascript创建新的div。 我的html表单中有一个选择框

<select name="seasonSelector" id="seasonSelector" onchange="jsSeason('seasonWrapper')">
我不确定我做错了什么,或者代码中没有包含什么


提前谢谢

x
是选择元素,您希望读取其值:

if (x.value == 2) {
    // ...
}
还要注意,您应该使用比较运算符
=
而不是赋值
=

if (x.value == 2) {
    // ...
}