简体   繁体   English

使用jQuery Uniform.js更改选择值

[英]Change Select value using jQuery Uniform.js

I'm using uniform.js for jQuery and I need to change the values of the select item programmatically. 我正在使用uniform.js进行jQuery,我需要以编程方式更改select项的值。 It seems to change the actual <select> field, but the uniform element doesn't change. 它似乎改变了实际的<select>字段,但统一元素不会改变。 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? 除了手动查找选项的HTML,然后将uniform元素设置为该值之外,执行此操作的正确方法是什么?

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();

Try to use the update command in the complete function: 尝试在完整功能中使用update命令:

$('.selectbox').load('index.php?get=newoptions',  function() {
  $.uniform.update('selectbox');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM