Re: [問題] jQuery width()

看板Ajax作者 (心中在下雨)時間14年前 (2011/07/07 01:08), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串2/2 (看更多)
※ 引述《Fantasywind (Fantasywind)》之銘言: : $("img.textPic").each(function(){ : var max_w = parseInt($(this).parent().css('width').replace("px",'')) - 30; : var max_h = parseInt($(this).parent().css('height').replace("px",'')) - 250; var tmp = new Image(); tmp.src = $(this).attr('src'); : var div = max_w / max_h; var img = tmp.width / tmp.height; : if (div > img){ : $(this).width(max_w); : } else { : $(this).height(max_h); : } : }) 此外 max_w 和 max_h 怎不用 $(this).parent().width() 來取? $(this) 呼叫很多次 可以在一開始的時後先丟進一個變數,會比較好 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.85.195.120

07/07 04:33, , 1F
謝謝你!原來Image有預讀得功能 學了一課!!
07/07 04:33, 1F

07/07 13:37, , 2F
學習了,感謝
07/07 13:37, 2F

07/16 15:24, , 3F
有沒有辦法對一個append的td用width()?
07/16 15:24, 3F
文章代碼(AID): #1E59P-3o (Ajax)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
文章代碼(AID): #1E59P-3o (Ajax)