gpt4 book ai didi

javascript - 在选择元素上使用 jqtransform 时如何设置选择的选项

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:26:42 24 4
gpt4 key购买 nike

如何设置在选择元素上使用 jqtransform 时选择的选项。

我正在为我的表单使用 jqtransform,我想设置适当的选项值,以便在我从数据库中检索保存的数据时选择。

最佳答案

我相信您会以与不使用 jqTransform 相同的方式设置 select 的值。

例如

$('#mySelect').val('myVal');

编辑:

好吧,这真的很难看,但应该可行:

var mySelect = $('#mySelect');

//find the current selected option
var myOption = mySelect.find('option[value='+mySelect.val()+']');

//find the index of that option
var index = $('#mySelect option').index(myOption);

//trigger the click on the corresponding jqTranfsform element
mySelect.prev('ul').find('li').eq(index).find('a').click();

关于javascript - 在选择元素上使用 jqtransform 时如何设置选择的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11402060/

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