我有一个输入字段,在模糊和焦点上调用函数"inputInlineHint(self)".它也通过自我......
<input type="text" id="one" class="textbox" value="Your Name" onfocus="inputInlineHint(self);" onblur="inputInlineHint(self);" />
Run Code Online (Sandbox Code Playgroud)
现在我想检索该字段的当前值:
function inputInlineHint(e) {
var theValue = '';
//Now i need to retrieve the value... but how?
}
Run Code Online (Sandbox Code Playgroud)
我希望你们可以帮助我...应该是非常基本但我是jquery的新手.
提前致谢!
this不通过self.self未定义.e为其他内容.e传统上用于接收事件对象,但您没有将该函数指定为事件处理程序whatever_you_renamed_e_to.value使用 jQuery 绑定函数比将脚本名称写入控件要好得多:
$(function() {
$('#one').focus(function() {
var value = $(this).val(); /// this is now the value
}).blur(function (){
var value = $(this).val(); /// same again
);
);Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3599 次 |
| 最近记录: |