朋友们好日子。我有一个问题......谢谢,如果你帮助我,我有几个输入到一个 div 中。我在 java 脚本中使用 Clone 函数复制了该 div(通过单击一个按钮),现在,我有两个 div。但我的问题:
1-我不知道,如何正确获取输入的值(输入的名称相同)?
2-我在 div 中有一个选择输入,通过选择选择输入的每个选项来添加或删除一些输入。现在复制 div 后,在 div2 中选择一个选项,在 div1 中创建更改...我不想要它!
<div class="levels">
<div class="add_senario_level">
<span>Level 1</span>
<form>
<select name="condition" onchange="show_div(this,'shop during');">
<option selected="selected" disabled="disabled">choose condition</option>
<option>shop after registration</option>
<option>shop during</option>
</select>
<div id="shop_during" style="display:none;">
<input type="number" id="shop_during_num" name="shop_during_num" placeholder="Enter number">
<select id="shop_during_time" name="shop_during_time">
<option selected="selected">hour after registeration</option>
<option>day after registeration</option>
<option>week after registeration</option>
<option>month after registeration</option>
</select>
</div>
<div>
<button type="button" class="newLevel"> Add New Level </button>
</div>
</form>
</div>
</div>
<script>
$(document).ready(function()
{
$(".newLevel").click(function()
{
$(".add_senario_level").clone().appendTo(".levels");
});
});
function show_div(obj, id)
{
txt = obj.options[obj.selectedIndex].text;
if (txt.match(id))
{
document.getElementById("shop_during").style.display = 'block';
}
else
{
document.getElementById("shop_during").style.display = 'none';
}
}
</script>