当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jquery 动态遍历select 赋值的实例

jquery 动态遍历select 赋值的实例

2018年09月21日  | 移动技术网IT编程  | 我要评论

获取select 选中的值:

$("#seldepunit").children('option:selected').val();

ajax 动态为select赋值:

$.ajax({
  type: "post",
  url: "/department/finddepbypid",
  data:"pid="+pid,
  success: function (data) {
  $("#seldep").empty();
  $.each(data, function(i, item){ 
   $("#seldep").append($("<option/>").text(item.name).attr("value",item.id));
   }); 
  },
});

以上这篇jquery 动态遍历select 赋值的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网