Javascript 使用 jQuery Uniform.js 更改选择值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7503091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Select value using jQuery Uniform.js
提问by solepixel
I'm using uniform.js for jQuery and I need to change the values of the select item programmatically. It seems to change the actual <select> field, but the uniform element doesn't change. What is the proper way to do this, other than manually looking up the HTML for the option, then setting the uniform element to that value?
我正在使用uniform.js for jQuery,我需要以编程方式更改选择项的值。它似乎改变了实际的 <select> 字段,但统一元素没有改变。除了手动查找选项的 HTML,然后将统一元素设置为该值之外,执行此操作的正确方法是什么?
回答by Sander
After setting the value as usual, you need to tell uniform to update the element.
像往常一样设置值后,您需要告诉uniform更新元素。
$.uniform.update("#myUpdatedSelect");
or as the documentation says, if you are lazy you can let it update ALL elements
或者正如文档所说,如果你很懒,你可以让它更新所有元素
$.uniform.update();
回答by Alexandre Mooze
Try to use the update command in the complete function:
尝试使用完整函数中的update命令:
$('.selectbox').load('index.php?get=newoptions', function() {
$.uniform.update('selectbox');
});