Javascript uired输入数据并在ittry周围播放它与使用select only没有什么不同!如果要在单击>>>时显示选项,为什么要使用输入文本:(显示/隐藏输入并选择?为什么要使用不可编辑的输入触发下拉列表? <script src="https:/
Javascript uired输入数据并在ittry周围播放它与使用select only没有什么不同!如果要在单击>>>时显示选项,为什么要使用输入文本:(显示/隐藏输入并选择?为什么要使用不可编辑的输入触发下拉列表? <script src="https:/,javascript,html,Javascript,Html,uired输入数据并在ittry周围播放它与使用select only没有什么不同!如果要在单击>>>时显示选项,为什么要使用输入文本:(显示/隐藏输入并选择?为什么要使用不可编辑的输入触发下拉列表? <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymo
uired输入数据并在ittry周围播放它与使用select only没有什么不同!如果要在单击>>>时显示选项,为什么要使用输入文本:(显示/隐藏输入并选择?为什么要使用不可编辑的输入触发下拉列表?
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
function addOption() {
val = $("#_textVal").val();
key = $("#_textVal").val();
if(val == ""){
alert("Insert Text");
return -1;
}
o = new Option(key, val);
$("#_sel").append(o);
$('#_textVal').val(""); }
function editOption(sel) {
val = sel.value;
$('#_textVal').val(val); }
</script>
<input type="text" placeholder="click on me" id="_textVal" value="10">
<button id="_btnSet" onclick="addOption();">Set Option</button>
<select id="_sel" onchange="editOption(this);"> </select>