【发布时间】:2019-03-03 00:08:38
【问题描述】:
嘿,我的 div 中有一个 div,看起来像这样
<div style="border-radius:2px;
background-color:#252525;
display:inline-block;margin-left:1.5%;
margin-right:1.5%;margin-top:1%;margin-bottom:1%;
width:94%;max-width:94%;min-width:94%;
height:100px;max-height:height:100px;
min-height:height:100px;
">
<span style="display:block;font-size:1.3em;
margin-bottom: 2px;
">Stats conditions</span>
<div style="margin-top:1%;">
<div style="margin-left:1.5%;
margin-right:1.5%;display:inline-block;width: 21%;min-width: 21%;max-width:21%">
<span style="display:block;font-size:0.8em">Gamemode</span>
<select id="ann" class="myselect" style="display:block;width: 100%;min-width: 100%;max-width:100%">
<option value="all">All</option>
<option value="solo">Solo</option>
<option value="duos">Duos</option>
<option value="squads">Squads</option>
</select>
</div>
<div style="margin-left:1.5%;
margin-right:1.5%;display:inline-block;width: 21%;min-width: 21%;max-width:21%">
<span style="display:block;font-size:0.8em">Stat type</span>
<select id="ann" class="myselect" style="display:block;width: 100%;min-width: 100%;max-width:100%">
<option value="kills">kills</option>
<option value="wins">wins</option>
<option value="kd">kd</option>
<option value="scrim-kills">scrim kills</option>
<option value="scrim-wins">scrim wins</option>
<option value="scrim-kd">scrim kd</option>
</select>
</div>
<div style="margin-left:1.5%;
margin-right:1.5%;display:inline-block;width: 21%;min-width: 21%;max-width:21%">
<span style="display:block;font-size:0.8em">Condition type</span>
<select id="ann" class="myselect" style="display:block;width: 100%;min-width: 100%;max-width:100%">
<option value="kills">Minimum</option>
<option value="wins">Maximum</option>
</select>
</div>
<div style="
align-tems:center;margin-left:1.5%;margin-right:1.5%;display:inline-block;width: 21%;min-width: 21%;max-width:21%">
<span style="display:block;font-size:0.8em">Enter number</span>
<input id="everyMinutes" style="font-family:Montserrat;
display:block;width: 100%;min-width: 100%;max-width:100%;
border-radius: 3px;border: none;height: 2.35em;
"
type="number" value="">
</div>
</div>
</div>
现在要添加其中的另一个,我并没有准确地添加它,而是在 select2 呈现它之后添加它,因此打开它并按 f12 并复制 HTML。现在要添加另一个这些 div,我将它添加到容器 HTML 中。现在,在添加一个之前,我单击了所有选择元素,它弹出来很好地显示了我的选项。现在,在我通过 innerHTML 方法添加了一个之后,选择不再起作用了
编辑:https://jsfiddle.net/qt0zvho3/443/ 编辑:将 div 添加到容器中: 点击左侧 div ==> 查看 ==> 添加统计要求
【问题讨论】:
标签: javascript html css jquery-select2 innerhtml