[jQuery] Snippet: serialize

[jQuery] Snippet: serialize

I found that there is a serialize function in API document, but it
doesnot be included in 1.0.1 yet, and the basic function is param. But
param should be used as:
$.param($('input,select,textarea'))
but the result seems not correct, I don't know why. And I made this
snippet to handy serialization, I hope it has some useful.
$.fn.serialize = function(){
var s = [];
$('input, select, textarea', this[0]).each(function (){
if (this.name)
s.push(this.name + '=' + encodeURIComponent(this.value));
});
return s.join('&');
}
example:
$('#main').serialize()
--
I like python!
My Blog: http://www.donews.net/limodou
UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad
UliPad Maillist: http://groups.google.com/group/ulipad
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/