我想爲jQuery使用typeWatch插件。我有此javascript:如何使用jQuery訪問輸入字段文本?
<script type="text/javascript">
$(document).ready(function() {
var options = {
callback: function() { alert("a-ok! " + $(this).text); },
wait: 333,
highlight: true,
captureLength: 1
}
$("#customer").typeWatch(options);
});
</script>
而我的觀點的HTML有這樣的:
Method B: <%= Html.TextBox("customer") %>
與這個測試,如果我在文本框中輸入「ABC」,我期待一個警報,「一個彈出-ok!ABC「。相反,下面顯示了......
a-ok! function (F) {
if (typeof F !== "object" && F != null) {
return this.empty().append((this[0] && this[0].ownerDocument ||
document).createTextNode(F));
}
var E = "";
o.each(F || this, function() {o.each(this.childNodes, function() {
if (this.nodeType != 8) {
E += this.nodeType != 1 ? this.nodeValue : o.fn.text([this]);}});});
return E;
}
我試圖改變$(本)的.text到.VAL,我也試着參考輸入領域更直接地爲$(「#客戶」 )但他們產生了類似的結果。我怎樣才能訪問輸入的文本?
你之所以回來函數的文本表示,是因爲你沒有調用函數使用parens ... 文本應該是文本***()*** – cgp 2009-06-03 13:27:39
我無法回答:( – cgp 2009-06-03 13:27:44