欢迎来到cool的博客
7

Music box

Click to Start

点击头像播放音乐
新博客链接

给下拉单设置默认值用jquey (Set the default value in dropdownlist using jQuery )

if your wanting to use jQuery for this, try the following code.

$('select option[value="1"]').attr("selected",true);

  if ($("#roomcategory_id").val() != null) {
    get_room_id_by_roomcategory_id($("#roomcategory_id").val());

    //加载rails的数据需要时间,需要延迟下个动作,否则取不到这个值.
    console.info("room id:  <%= @check_in_order.room_id %>")
    setTimeout(function(){
      $('select#room_id option[value="<%= @check_in_order.room_id %>"]').attr("selected",true);
    }, 100)
  }


返回列表