大家好我試着當用戶使用jQuery點擊文本框獲取文本框的值,但是當我用警報()看到的值這裏是我的了:jquery - 如何從文本框中獲取值?
function (value) {
var hooks, ret, elem = this[0];
if (!arguments.length) {
if (elem) {
hooks = jQuery.valHooks[elem.nodeName.toLowerCase()] ||
jQuery.valHooks[elem.type];
if (hooks &&
"get" in hooks &&
(ret = hooks.get(elem, "value")) !== undefined) {
return ret;
}
ret = elem.value;
return typeof ret === "string" ? ret.replace(rreturn, "") : ret == null ? "" : ret;
}
return undefined;
}
var isFunction = jQuery.isFunction(value);
return this.each(function (i) {var self = jQuery(this), val;if (this.nodeType !== 1) {return;}if (isFunction) {val = value.call(this, i, self.val());} else {val = value;}if (val == null) {val = "";} else if (typeof val === "number") {val += "";} else if (jQuery.isArray(val)) {val = jQuery.map(val, function (value) {return value == null ? "" : value + "";});}hooks = jQuery.valHooks[this.nodeName.toLowerCase()] || jQuery.valHooks[this.type];if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) {this.value = val;}});}
這裏是我的代碼:http://jsfiddle.net/QYHXu/1/
請幫忙。提前致謝。
哦,我明白了......非常感謝。 – NinjaBoy