如何设置在选择元素上使用 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/