2011年12月14日 星期三

jQuery 解決select 下拉被截斷(支援連動兩個select)

找了很久終於找到jquery改變select長度被截斷的問題

原程式網頁的網頁點我

但如果是連動例如DropDownList1連動DropDownList2就必需要用jquery live(邊學邊做系列有教大家可以去看看)

好像要jQuery 1.3.2版後才有這功能喔

 
$(function() {
$("#ctl00_ContentPlaceHolder1_DropDownList2")
.live("focus", function() {
$(this).data("selectWidth", $(this).css("width")).css("width", "auto");
$(this).css({ position: "absolute" });
})

$("#ctl00_ContentPlaceHolder1_DropDownList2")
.live("blur", function() {
$(this).css("width", $(this).data("selectWidth"));

}) 
});