Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何申请;精选;jQuery中的元素?_Jquery_Html_Selectedvalue - Fatal编程技术网

如何申请;精选;jQuery中的元素?

如何申请;精选;jQuery中的元素?,jquery,html,selectedvalue,Jquery,Html,Selectedvalue,我想将数字90设为默认值。 有人知道如何将下面HTML中的选中的元素应用到jQuery中吗 HTML中的示例 <select id="threshold"> <option value="90" selected>90</option> /* example selected in HTML */ </select> 只需通过在对象中添加selected:true来告诉jQuery应该选择哪一个 const选项=[ {值:“70”,

我想将数字90设为默认值。 有人知道如何将下面HTML中的
选中的
元素应用到jQuery中吗

HTML中的示例

<select id="threshold">
    <option value="90" selected>90</option>   /* example selected in HTML */
</select>

只需通过在对象中添加
selected:true
来告诉jQuery应该选择哪一个

const选项=[
{值:“70”,文本:“70%”
,{值:“80”,文本:“80%”
,{值:“90”,文本:“90%”,所选值:true}
];
$(“#阈值”).append(options.map(o=>$(“”,o))

或者

$("#threshold").append($("<option>",{ value: "90",text: "90%", selected:true }));
$(“#阈值”).append($(“”,{value:“90”,text:“90%”,selected:true});
$(“阈值”)
.append($(“”,{值:“70”,文本:“70%”)
.append($(“”,{值:“80”,文本:“80%”)
.append($(“”,{value:“90”,text:“90%”,selected:true}))

已选择:true
$("#threshold").append($("<option>",{ value: "90",text: "90%", selected:true }));