function resize(which, max) { var elem = document.getElementById(which); if (elem == undefined || elem == null) return false; if (max == undefined) max = 100; if (elem.width > elem.height) { if (elem.width > max) elem.width = max; } else { if (elem.height > max) elem.height = max; } }
becomes $.fn.resize = function(max) { max = max || 100; this.each(function() { if(this.width > this.height && this.width > max) this.width = max; else if(elem.height > max) elem.height = max; }); }; and you'd call it as $().resize(max); Eventually, you'll do something like: $(document).ready(function() { $("input selector").blur(function() { $("thing to resize").resize(max) }); }); On 8/6/07, LSUDVM <[EMAIL PROTECTED]> wrote: > > > Hi, > I need help in converting this to jquery: > > function resize(which, max) { > var elem = document.getElementById(which); > if (elem == undefined || elem == null) return false; > if (max == undefined) max = 100; > if (elem.width > elem.height) { > if (elem.width > max) elem.width = max; > } else { > if (elem.height > max) elem.height = max; > } > } > > I an just know really getting into jquery but not sure how to convert > tis. My aim to be able to this function onblur of the file input field > - if possible. > > -- Yehuda Katz Web Developer | Procore Technologies (ph) 718.877.1325