> The API says that $.val() will: > Get the current value of the first matched element. Yes, it is equivalent to $().attr("value") so it gets the value attribute of the first element. > The API says that $.val( string ) will: > Set the value of every matched element.
Yes, it will set a "value" attribute for each element, regardless of whether the doctype indicates the element has a "value" attribute. Generally you'd only want to use .val() in cases where the element responded to having a "value" attribute though. > The only indications in the API that this only works on the > input element is that the examples following both methods > use the input element. There's no other indication, so I > am surprised to find that it only works on this element. I think the word "works" means "makes sense" here. What should $("div").val() return? Right now it would be undefined since usually a div has no value attribute. I could see an interpretation where it might return the text nodes inside the div, but $().text() already does that. _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/