从输入添加选择选项(IE错误)

时间:2016-05-04 11:16:54

标签: javascript jquery forms drop-down-menu

我尝试从输入字段向表单添加选择选项。我在所有浏览器中都能正常工作,除了IE似乎没有添加选项。感谢帮助!

HTML

<select name="folder" id="folder" class="select Slectbox">
</select>

<label for="addfolder">Add Folder</label>
<input type="text" class="input-add-list" placeholder="new folder name" />
<button onClick="return false;" class="spr btn">Add</button>

JQUERY

<script>
$('.spr').on('click',function(){
    if($('.input-add-list').val().trim()!=='')
    {
        $('.SlectBox').append('<option value="'+$('.input-add-list').val().trim()+'">'+$('.input-add-list').val().trim()+'</option>');
        $("select option:last").attr("selected","selected");
    }
});
</script> 

0 个答案:

没有答案