gpt4 book ai didi

javascript - jQuery 模板选择选项

转载 作者:行者123 更新时间:2023-11-28 11:19:19 26 4
gpt4 key购买 nike

如何使用 jQuery 模板来选择选项?

假设我的数据是:{ "color": "red"}

我有:

<select>
<option>blue</option>
<option>green</option>
<option>red</option>
</select>

我希望默认选择红色。我怎样才能做到这一点?

谢谢。

最佳答案

$("select").val(data['color']);

关于javascript - jQuery 模板选择选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4939599/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com