用jquery选择下拉列表..服务不是在重新调整它正在重新调整字符串的id [英] select the dropdown with jquery .. service is not returing the id it is retuning the string

查看:70
本文介绍了用jquery选择下拉列表..服务不是在重新调整它正在重新调整字符串的id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



需要帮助..

我有一个下拉列表,下面的值很少



性别

Hi Friends,

Need a help ..
I have a dropdown with few values like below

Gender

<select class="form-control" tabindex="6" id="ddlSex">
   <option value="M">Female</option>
   <option value="N">Male</option>
</select>



服务返回性别为N,但没有id与它协商

如何分配基于性别=N通过jquery尝试这样的事情


service returning the Gender as "N" but there is no id assosicated with it
how to assign based on Gender="N" through jquery tried something like this

$.each(item.Sex, function (i,item1) {
      if (i == 'N') {
          $("#ddlSex").val(item1.Sex).trigger('change');
      }
  });



但它正在抛出运行时错误消息..有人可以帮我怎么做


but it is throwing runtime error message .. can someone help me how to do it

推荐答案

.each(item.Sex, function (i,item1){
if (i == ' N'){
.each(item.Sex, function (i,item1) { if (i == 'N') {


(< span class =code-string> #ddlSex)。val(item1.Sex).trigger(' 更改');
}
});
("#ddlSex").val(item1.Sex).trigger('change'); } });



但它会抛出运行时错误消息..有人可以帮我怎么做


but it is throwing runtime error message .. can someone help me how to do it


使用下面的代码取代


这篇关于用jquery选择下拉列表..服务不是在重新调整它正在重新调整字符串的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆